-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsample.py
More file actions
101 lines (87 loc) · 2.84 KB
/
Copy pathsample.py
File metadata and controls
101 lines (87 loc) · 2.84 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import random
level = 2
score = 0
def Level1():
global level
global score
while 1:
print(f"Level {level} \n Score {score}")
listt = ['-','+','*']
random_operator = random.sample(listt,1)
ist = random.randint(0,10)
second = random.randint(0,10)
if random_operator[0] == '-':
answer = ist - second
print(f"{ist} {random_operator[0]} {second} = ?: \n")
user_answer = int(input("Enter answer:"))
if user_answer == answer:
print("you won!")
score += 1
else:
score -= 1
print("wrong answer")
elif random_operator[0] == '*':
answer = ist * second
print(f"{ist} {random_operator[0]} {second} = ?: \n")
user_answer = int(input("Enter answer"))
if user_answer == answer:
score += 1
print("you won!")
else:
score -= 1
print("wrong answer")
if random_operator[0] == '+':
answer = ist + second
print(f"{ist} {random_operator[0]} {second} = ?: \n")
user_answer = int(input("Enter answer"))
if user_answer == answer:
score += 1
print("you won!")
else:
score -= 1
print("wrong answer")
def Level2():
global level
global score
while 1:
print(f"Level {level} \n Score {score}")
listt = ['-','+','*']
random_operator = random.sample(listt,1)
ist = random.randint(20,100)
second = random.randint(20,100)
if random_operator[0] == '-':
answer = ist - second
print(f"{ist} {random_operator[0]} {second} = ?: \n")
user_answer = int(input("Enter answer"))
if user_answer == answer:
print("you won!")
score += 1
else:
score -= 1
print("wrong answer")
elif random_operator[0] == '*':
answer = ist * second
print(f"{ist} {random_operator[0]} {second} = ?: \n")
user_answer = int(input("Enter answer"))
if user_answer == answer:
score += 1
print("you won!")
else:
score -= 1
print("wrong answer")
if random_operator[0] == '+':
answer = ist + second
print(f"{ist} {random_operator[0]} {second} = ?: \n")
user_answer = int(input("Enter answer"))
if user_answer == answer:
score += 1
print("you won!")
else:
score -= 1
print("wrong answer")
# # def main():
if level == 1:
Level1()
if level == 2:
Level2()
# main()