View Single Post
  #18 (permalink)  
Old 02-27-2008, 10:03 PM
nolls nolls is offline
Newbie
 
Join Date: Jan 2008
Posts: 18
Rep Power: 4
nolls is on a distinguished road
Default

Ok thanks for the advice void . Here is the new code:

Code:
import random
print "Welcome to the Guess a Number game"
print "Goal: To guess the number the computer is thinking of"
number = 0
while number != 6:
    compnum = random.randint(1, 5)
    print "1. Number 1"
    print "2. Number 2"
    print "3. Number 3"
    print "4. Number 4"
    print "5. Number 5"
    print "6. Exit"
    number = input("Which number would you like to guess? ")
    if compnum >= 1 and compnum <= 5:
        if compnum > number:
            print "Too low, try again"
        elif compnum < number:
            print "Too high, try again"
        elif compnum == number:
            print "You guessed the right number, congrats!"
I have some questions I would still like to ask though.

Does randint mean random integers? Wouldn't randrange work also (while looking into module random that was what randrange was said to do, integers between parameters)?

What did you mean by hardcode? And is this good enough or can it be modified further?

Oh and is a floating number just a decimal/integer? Forgot the meaning of it .

Last edited by nolls; 02-27-2008 at 10:12 PM.
Reply With Quote