forked from geekcomputers/Python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGuess_the_number_game.py
More file actions
42 lines (30 loc) · 798 Bytes
/
Guess_the_number_game.py
File metadata and controls
42 lines (30 loc) · 798 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# using codeSkulpter
import random
import simplegui
def new_game():
global num
print("new game starts")
def range_of_100():
global num
num = random.randrange(0, 100)
print("your range is 0-100")
def range_of_1000():
global num
num = random.randrange(0, 1000)
print("Your range is 0-1000")
def input_guess(guess):
global num
print("Your Guess is ", guess)
num1 = int(guess)
if num1 == num:
print("Correct")
elif num1 >= num:
print("Greater")
elif num1 <= num:
print("Lower")
frame = simplegui.create_frame("Guess The Number", 200, 200)
frame.add_button("range[0-1000)", range(1000))
frame.add_button("range[0-100)", range(100))
frame.add_input("enter your guess", input_guess, 200)
frame.start()
new_game()