Python猜数字游戏
def guessnum(): guess,count=0,1 rand=random.randint(1,101) print (‘you just have five time‘) guess=int(input(‘please enter your guess num:‘)) while True: if guess > rand: print(‘too large‘) elif guess < rand: print(‘too small‘) elif guess == rand: print (‘you are so lucky ‘) break count=count+1 print (‘you just have ‘+str(5-count+1)+‘ times‘) guess=int(input(‘please enter your num again:‘)) if count == 5: print (‘sorry,your are lose,the secret num is ‘+str(rand)) break
本文出自 “侯大傻不傻” 博客,请务必保留此出处http://zqlhyj.blog.51cto.com/6299641/1576070
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。