Odd or Even Checker

Write a Python program that asks for an integer from the user and checks if the number is even or odd. Print out an appropriate message to the console.

Example:

Input: 5 

Output: "Odd"

Input: 10 

Output: "Even"

Remember the modulus operation in Python. The modulus of a number by 2 can help determine if a number is even or odd.

num = int(input("Enter a number: "))
if num % 2 == 0:
print(f"The number {num} is even.")
else:
print(f"The number {num} is odd.")

© Let’s Data Science

LOGIN

Unlock AI & Data Science treasures. Log in!