python进阶练习之——骰子模拟器

278 阅读1分钟
目的:创建一个程序来模拟掷骰子。
提示:当用户询问时,使用random模块生成一个16之间的数字。
import random;
while int(input('Press 1 to roll the dice or 0 to exit:\n')): print( random. randint(1,6))
--------------------------------------------------------------------
Press 1 to roll the dice or 0 to exit
1
4