我们先来看一下效果:
代码如下:
import random,time
#首先初始化
number1 = 0
number2 = 0
answer1 = 0
answer2 = 0
score = 0
chance = 5
#在机会用光前重复执行
while chance != 0:
number1 = random.randint(1, 100)
number2 = random.randint(1, 100)
answer2 = number1 +number2