We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8dec512 commit f7c44a4Copy full SHA for f7c44a4
newcodes/answers/q43.py
@@ -0,0 +1,27 @@
1
+#!/usr/bin/env python
2
+# coding=utf-8
3
+
4
5
+#coding:utf-8
6
7
+import random
8
9
+number = random.randint(1,100)
10
+guess = 0
11
12
+while True:
13
+ num_input = input("please input one integer that is in 1 to 100:")
14
+ guess += 1
15
16
+ if not num_input.isdigit():
17
+ print("Please input interger.")
18
+ elif int(num_input) < 0 or int(num_input) >= 100:
19
+ print("The number should be in 1 to 100.")
20
+ else:
21
+ if number == int(num_input):
22
+ print("OK, you are good.It is only {0}, then you successed.".format(guess))
23
+ break
24
+ elif number > int(num_input):
25
+ print("your number is smaller.")
26
+ elif number < int(num_input):
27
+ print("your number is bigger.")
0 commit comments