Toggle navigation
Home
Latest pastes
FAQ
Random
BitBin is shutting down!
Register
Login
Guess the number game
SUBMITTED BY:
Guest
DATE:
Dec. 7, 2014, 3:29 p.m.
FORMAT:
Python
SIZE:
1.6 kB
Raw
Download
Tweet
HITS:
1130
Go to comments
Report
import
random
import
time
def
GetNumber
():
number
=
random
.
randint
(
0
,
10
)
return
number
while
True
:
y
=
1
x
=
1
while
y
==
1
:
number
=
GetNumber
()
while
x
==
1
:
print
'Guess the number between 0 and 10'
Guess
=
input
(
''
)
if
Guess
<
0
:
print
'You entered a negative number! The number is not a negative!'
time
.
sleep
(
1
)
print
'Guess the number between 0 and 10'
time
.
sleep
(
1
)
elif
Guess
<
number
:
print
'Your guess is wrong! You guessed lower than the number'
time
.
sleep
(
1
)
elif
Guess
>
number
:
print
'Your guess is wrong! You guessed higher than the number'
time
.
sleep
(
1
)
elif
Guess
==
number
:
time
.
sleep
(
1
)
print
'Congratulations! You guessed correctly!'
time
.
sleep
(
1
)
print
'Would you like to go again?'
print
'[1] Yes'
print
'[2] No'
answer
=
input
(
''
)
if
answer
==
1
:
break
else
:
time
.
sleep
(
1
)
print
'Thank you for playing! Hope to see you again soon!'
time
.
sleep
(
1
)
quit
()
Please enable JavaScript to view the
comments powered by Disqus.
comments powered by
Disqus