【发布时间】:2021-12-18 04:02:52
【问题描述】:
我正在制作一个用于练习的小型数学程序。
用户应该输入,两个和应该有多少位数。
如下图所示:
import random
digits = int(input("How many digits should the numbers have? "))
if digits == 1:
while True:
num1 = random.randint(0,9)
num2 = random.randint(0,9)
solution = num1 + num2
print(str(num1) + " + " + str(num2) + " = ? ")
question = int(input())
如何使流程自动化,这样我就不必在数字增加时手动添加数字?
【问题讨论】: