标签:NPU break random input python基础 sse else more games
1 # Author:"Mamba" 2 3 import random 4 setNum = random.randint(1,10) 5 #print(setNum) 6 count = 0 7 while count == 0: 8 print(‘let`us play guess number games‘) 9 print(‘your have three times ,now begin‘) 10 guess = int(input("please input your number:")) 11 if guess == setNum: 12 print("great ,so clever you are") 13 break 14 elif guess < setNum: 15 print(‘{0}{1}{2}{3}{4}‘.format(‘sorry,‘, ‘the number you guessed is small,‘, ‘and you have ‘, (2 - count), ‘ more chances.‘)) 16 else : 17 print(‘{0}{1}{2}{3}{4}‘.format(‘sorry,‘, ‘You guessed a big number,‘, ‘and you have ‘, (2 - count),‘ more chances.‘)) 18 count =count +1 19 break 20 while count < 3: 21 guess = int(input("please input your number again:")) 22 if guess == setNum: 23 print("great ,so clever you are") 24 break 25 elif guess < setNum: 26 print(‘{0}{1}{2}{3}{4}‘.format(‘sorry,‘, ‘the number you guessed is small,‘, ‘so you have ‘, (2 - count), ‘ more chances.‘)) 27 else : 28 print( ‘{0}{1}{2}{3}{4}‘.format(‘sorry,‘, ‘You guessed a big number,‘, ‘so you have ‘, (2 - count), ‘ more chances.‘)) 29 count =count +1 30 else : 31 print("you have tried too many times ,game over")
标签:NPU break random input python基础 sse else more games
原文地址:https://www.cnblogs.com/mamba-T/p/10292160.html