Python

predict squares

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from randomstate import randint
rounds = 0
score = 0
a=0
print("welcome! would you like to practice finding square roots(1) or squares(2)?")
practice = int(input())
while rounds!=10:
  rounds=rounds+1
  b=0
  a = int(randint(10, 99))
  if practice == 1:
    print(a*a)
  elif practice == 2:
    print(a)
  b = int(input())
  if (practice==1 and a==b) or (practice==2 and a*a==b):
    print("good job! ")
    score=score+1
  elif (practice==1 and a!=b) or (practice==2 and a*a!=b):
    print("sorry, it was ", a," (or it could be ", a*a,")")
  else:
    print("err. you shouldn't see this")
print("your score is ", score)