shell

python 3.5 猜数字游戏

 1 #!/usr/bin/env python
 2 #encoding: utf-8
 3 number = 88
 4 
 5 for i in range(1,6):
 6     num = int(input('gusee number game(5 机会):'))
 7     print('第 %s 机会' % (i))
 8     if num >number:
 9         print ('big')
10     elif num < number:
11         print ('small')
12     elif num == number:
13         print ('good')
14         break
15 
16 if num == number:
17     print ('good luck')
18     print ('welcome to next come on.......')
19 else:
20     print ('no good luck')
21     print('welcome to next come on.......')
 1 #!/usr/bin/env python
 2 #encoding: utf-8
 3 number = 88
 4 
 5 a = 1
 6 while a <= 5:
 7     num = int(input('gusee number game(5 机会):'))
 8     print('第 %s 机会' % (a))
 9     if num >number:
10         print ('big')
11     elif num < number:
12         print ('small')
13     elif num == number:
14         print ('good')
15         break
16     a += 1
17 
18 if num == number:
19     print ('good luck')
20     print ('welcome to next come on.......')
21 else:
22     print ('no good luck')
23     print('welcome to next come on.......')

 

posted @ 2016-10-30 09:05  devops运维  阅读(323)  评论(0编辑  收藏  举报
python