标签: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