File tree 5 files changed +54
-79
lines changed
5 files changed +54
-79
lines changed Original file line number Diff line number Diff line change
1
+ #a = '19'
2
+ #print "please input a int number in 1-100"
3
+ #x = raw_input()
4
+ #if a != x:
5
+ # print "sorry you are wrong!\ninput again:"
6
+ # x = raw_input()
7
+ #else
8
+ # print "you are right"
9
+ #raw_input()
10
+
11
+ from random import randint
12
+
13
+ def printNum ():
14
+
15
+ sInput = raw_input (u"请输入你猜的数字(1-100):" )
16
+
17
+ try :
18
+ nInput = int (sInput )
19
+ except (ValueError ,TypeError ),diag :
20
+ print str (diag )
21
+
22
+ if (nInput < 1 or nInput > 100 ):
23
+ print u"你数字不在范围之内,请重新输入"
24
+
25
+ return nInput
26
+
27
+ def main ():
28
+
29
+ nValue = randint (1 ,100 )
30
+ nInput = printNum ()
31
+ nTotal = 1
32
+
33
+ while (nValue != nInput ):
34
+
35
+ if (nValue > nInput ):
36
+ print u"你猜的数小了"
37
+
38
+ elif (nValue < nInput ):
39
+ print u"你猜的数大了"
40
+
41
+ nTotal += 1
42
+ nInput = printNum ()
43
+
44
+ print u"恭喜你猜对了"
45
+ print u"你直到猜对 共猜了%d次" % nTotal
46
+
47
+ if nTotal < 10 :
48
+ print u"恭喜,你的成绩超过了平均水平"
49
+ else :
50
+ print u"很遗憾,你成绩没达到平均水平"
51
+
52
+
53
+ if __name__ == "__main__" :
54
+ main ()
Load Diff This file was deleted.
Load Diff This file was deleted.
Load Diff This file was deleted.
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments