码迷,mamicode.com
首页 > 其他好文 > 详细

四则运算

时间:2020-12-04 10:49:38      阅读:6      评论:0      收藏:0      [点我收藏+]

标签:while   选择   imp   dom   code   load   append   put   inf   

技术图片

 

 技术图片

 

 

 

 

import random
import math
import fractions
q=[]
ans=[]
def c1(q,ans)
symble = random.choice([‘+‘,‘-‘,‘*‘,‘/‘])
if symble == ‘+‘:
n1 = random.randint(0,20)
n2 = random.randont(0,20)
q.append(str(n1) + ‘+‘ + str(n2) + ‘=‘)
ans.append(n1+n2)
elif symble == ‘-‘:
n1 = random.randint(0,20)
n2 = random,randint(0,20)
n1,n2=max(n1,n1),min(n1,n2)
q.append(str(n1) + ‘-‘ + str(n2) + ‘=‘)
ans.append(n1-n2)
elif symble == ‘*‘
n1 = random.randint(0,20)
n2 = random,randint(0,20)
q.append(str(n1) + ‘*‘ + str(n2) + ‘=‘)
ans.append(n1*n2)
else:
n1 = random.randint(0,20)
if n1 == 0
n2 = random.randint(1,20)
else:
n2 = random.randint(1,n1+1)
q.append(str(n1) + ‘/‘ + str(n2) + ‘=‘)
ans.append(fractions.Fraction(n1,n2))
n = k = int(input(‘请输入你需要生成的几道题:‘))

import random
import math
import fractions
q=[]
ans=[]
def c1(q,ans)
symble = random.choice([‘+‘,‘-‘,‘*‘,‘/‘])
if symble == ‘+‘:
n1 = random.randint(0,20)
n2 = random.randont(0,20)
q.append(str(n1) + ‘+‘ + str(n2) + ‘=‘)
ans.append(n1+n2)
elif symble == ‘-‘:
n1 = random.randint(0,20)
n2 = random,randint(0,20)
n1,n2=max(n1,n1),min(n1,n2)
q.append(str(n1) + ‘-‘ + str(n2) + ‘=‘)
ans.append(n1-n2)
elif symble == ‘*‘
n1 = random.randint(0,20)
n2 = random,randint(0,20)
q.append(str(n1) + ‘*‘ + str(n2) + ‘=‘)
ans.append(n1*n2)
else:
n1 = random.randint(0,20)
if n1 == 0
n2 = random.randint(1,20)
else:
n2 = random.randint(1,n1+1)
q.append(str(n1) + ‘/‘ + str(n2) + ‘=‘)
ans.append(fractions.Fraction(n1,n2))
n = k = int(input(‘请输入你需要生成的几道题:‘))

n=int(input())
result =[]
m=0
while m<=(n-1):
    print(m+1,end=‘、‘)
    result .append(t())
    print(‘ ‘)
    m=m+1
m=0
print(‘对应的答案:‘)
while m<=(n-1):
    print(m+1,‘、‘,result [m])
    m=m+1
print(‘选择想要的模式‘)
print(‘1、进行四则运算‘)
print(‘2、制作题库‘)
n=int(input())
if n1:
while True:
result = t()
j= input()
s= int(j)
if s result :
print(‘right‘)
else:
print(‘error.,the answer is‘, result )

 

四则运算

标签:while   选择   imp   dom   code   load   append   put   inf   

原文地址:https://www.cnblogs.com/zjz-blog/p/14057479.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!