Tuesday, February 15, 2011

Tuesday

Working in the examples I found an interesting one that is about the events and odds number which is this code.

number = float(input("Tell me a number: "))
if number % 2 == 0:
    print(int(number), "is even.")
elif number % 2 == 1:
    print(int(number), "is odd.")
else:
    print(number, "is very strangeris very stranger.")

This is a very interesting because if I put  number 2 this program will tell me if this is and even or odd number. This program will tell you any number you put in, even if the number is negative.

No comments:

Post a Comment