除法小游戏
import randomscore = 0
while score < 4:
alan = answer = random.randint(1,500)
secret = int(input('请输入一个数字吧:'))
number = answer / secret
print('正确答案除以你的数字等于:',number)
yours = int(input('请输入正确的答案:'))
if yours == answer:
print('回答正确')
score += 1
print('累计得分为;',score)
else:
based = alan / yours
print('答错了,再想一想')
print('正确答案除以你的答案等于:',based)
print('请你再猜测一下正确答案')
yours = int(input('请输入正确的答案:'))
if yours == answer:
print('回答正确')
score += 1
print('累计得分为:',score)
print('当前得分:',score)
else:
print('回答错误,进入下一轮')
print('游戏结束,全部正确')
通过对变量进行赋值,得到变量之间相除的商,从而求出正确答案的程序
页:
[1]