我想使用从列表中随机选择的输出,稍后再次使用相同的输出。我如何使用随机输出给出的相同输出,而不是给出另一个随机输出?
这是我目前的代码:
print("Good you will have to do two things, first answer my question, second
guess my number")
speed = int(input("What is the top mph you have reached in the last week?"))
time = ('5','10')
print('You have traveled at' ,speed, 'mph for' ,random.choice(time),
'hours.' )
distance = int(input('How many miles have you traveled?'))
if distance == speed * int(random.choice(time)):
print('Good job, now simply guess my number.')
else:
print("Better luck next time, looks like you don't know your velocity equation")
“int(random.choice(time))”是我想使用与上面两行打印相同的输出。
对不起,如果这是一个容易提出的问题,这是我第一次使用python进行编码。