-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrandomgame.py
More file actions
27 lines (24 loc) · 783 Bytes
/
randomgame.py
File metadata and controls
27 lines (24 loc) · 783 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
# -*- coding: utf-8 -*-
"""
Created on Thu Jun 27 08:03:33 2019
@author: Robin
"""
from random import randint
from turtle import numinput, done
def tt_game():
num = randint(1, 100)
t = 1
inputn = numinput('Guess a number', 'Guess a number that between 1 and 100:')
while True:
if num == inputn:
o = '''%s was the number! You win! You just try %s time! Please press [cancel] or input '0' to exit.''' % (round(num), t)
numinput('Guess right', o)
done()
break
elif num < inputn:
inputn = numinput('Guess again', 'Guess lower!')
t += 1
elif num > inputn:
inputn = numinput('Guess again', 'Guess higher!')
t += 1
tt_game()