如何在python中找到掷骰子程序的最小值和最大值

import random

print(' \t Welcome rolling dice game\n ')



while True :

 input(' Press any key to roll')

 roll=random.randint(1,6)

 print(roll)


 stop= input( ' you want to roll. again ? \n if yes then enter y \n if not then enter n\n ')

 if stop=='y':

   continue

 elif stop=='n':

   break



print(' Thanks for Playing:')


偶然的你
浏览 188回答 1
1回答

守候你守候我

尝试:min = 6max = 0while True :&nbsp; &nbsp;input(' Press any key to roll')&nbsp; &nbsp;roll=random.randint(1,6)&nbsp; &nbsp;print(roll)&nbsp; &nbsp;if roll>max:&nbsp; &nbsp; &nbsp; max = roll&nbsp; &nbsp;if roll<min:&nbsp; &nbsp; &nbsp; min = roll
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python