Python Project: GuEsS tHe NuMbEr

For this, you could download the python from here

You could copy the program below and add some more!

“””A game””””””A game”””
from random import randintfrom time import sleep
def get_user_guess():    user_guess = int(raw_input(“Guess a number: “))    return user_guess
def roll_dice(number_of_sides):    first_roll = randint(1, number_of_sides)    second_roll = randint(1, number_of_sides)    max_value = number_of_sides * 2    print “The maximum possible value is: ” + str(max_value)    sleep(1)    user_guess = get_user_guess()    if user_guess > max_value:        print “No guessinc higher than the maximum possible value!”        return    else:        print “Rolling…”    sleep(2)    print “The first value is: %d” % first_roll    print “The second value is: %d” % second_roll    sleep(1)    total_roll = first_roll + second_roll    if user_guess > total_roll:    print “You won!”    return    else:    print “You lost, try again.”    return    roll_dice(6)


With this program, you will be playing a game where you will think of a number and then the computer will randomly generate two numbers and add them together. If your number that you’ve guessed is higher than the two numbers added together than you win! But if it’s less than you lose.

Yours truly,


2 thoughts on “Python Project: GuEsS tHe NuMbEr

Comments are closed.