女朋友用Python实现的猜数字游戏:)
1 from random import randint
2
3 def ran():
4 return randint(1,100)
5
6 c=ran()
7
8 # Guess
Number
9 # Writen By
小乖乖
10 count=0
11
while(count<5):
12
13
a=input()
14
15
if a>c:
16 print "too large ,try again"
17
elif a<c:
18 print "too small, again"
19
else:
20
print "good
,right"
21 print "count number
times=",count+1
22 break
23
count=count+1
24 else:
25 print "answer=",c
26
27
Posted By 九天雁翎 at 九天雁翎的博客 on 2009年02月03日