首页 > 其他 > 详细

四则运算

时间:2020-11-29 22:55:30      阅读:30      评论:0      收藏:0      [点我收藏+]

技术分享图片

 

 技术分享图片

 

 

 

 

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 )

 

四则运算

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!