Monday, February 14, 2011

Monday

Working on a example of python3 I found  commands that make application that ask you for a  number. This add would ask to guess a number and depending on what you type it will said "That number is too big." or if the number is low "This number is too low."

Python3
Command line.

number = 200
guess = 0

while guess != number:
    guess = int(input ("Guess a number: "))
    if guess > number:
        print("That number is too high.")
    elif guess < number:
        print("That number is too low.")
    else:
        print("Just right")


If you see at the top of the command line where it said (number=200) this is the number that will give you a message saying "Just right".
Look if I put a number that is higher than 200.

 and now look if I put a lower number.


However look when I put the correct number which is 200.


 This application will ask you for a number until you get the right number and it will keep saying that the number is too high or low. This will depend on the number you put when it ask you.

No comments:

Post a Comment