Python | Guess the secret number!

/ 26 Jul 2013 /
Upon learning about the 'random' module, I made a little guessing game, enjoy..



 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
import random
x = random.randint(1, 100)
while 1:
    v = int(input('Guess the number between 1 and 100!: '))
    if v == x:
        print('That\'s right! The secret number is ', x)
    elif v > x:
        print('That\'s too high!')
    elif v < x:
        print('That\'s too low!')
    else:
        print('Please choose a number between 1 and 100!!')
 
Copyright © 2010 M(ath)+me, All rights reserved