Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d4f7f2f

Browse files
committed
new file: expand/1.py
deleted: python_base/2_1.py deleted: python_base/2_2.py deleted: python_base/2_3.py deleted: python_base/2_4.py
1 parent 9250971 commit d4f7f2f

File tree

5 files changed

+54
-79
lines changed

5 files changed

+54
-79
lines changed

expand/1.py

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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()

python_base/2_1.py

-34
This file was deleted.

python_base/2_2.py

-13
This file was deleted.

python_base/2_3.py

-16
This file was deleted.

python_base/2_4.py

-16
This file was deleted.

0 commit comments

Comments
 (0)