1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | import random x=int(input("Your chosen number:")) y=round(random.uniform(0,100)) sum=0 times=0 while x!=999999: if x>100: print('輸入錯誤QAQ') x=int(input("Your next chosen number:")) elif x>y: print('太大了!') sum+=1 x=int(input("Your next chosen number:")) elif x<y: print('太小囉~') sum+=1 x=int(input("Your next chosen number:")) else: sum+=1 times+=1 print("正確!") print('遊玩次數: '+str(sum)+'次') ab=input("再來一次?") if ab=="No": break y=round(random.uniform(0,100)) x=int(input("Your chosen number:")) sum*=0 print('遊戲結束,你總共玩了'+str(times)+'次') |
Direct link: https://paste.plurk.com/show/ESHo97ll9EV5lUcjKanm