Program 40: Take a number as input and print whether it is even or odd


Question: Write a Python Program that takes a number as input and prints whether it is even or odd.


Solution:

user_input_number = int(input("Enter a number: "))

if (user_input_number % 2) == 0:
   print(f"The user inputted number {user_input_number} is even!")
else:
   print(f"The user inputted number {user_input_number} is odd!")
Output:

Enter a number: 71
The user inputted number 71 is odd!


Notebook Example:

Notebook Demo - Even Odd Python

These Python programs are created by experienced programmers to aid students in learning Python. We are here to make your learning experience as interactive and informative as possible. If you have questions or need more clarification, feel free to ask. Happy coding!

Please support independent contributors like Code2care by donating a coffee.

Buy me a coffee!

Buy Code2care a Coffee!

Comments & Discussion

Facing issues? Have questions? Post them here! We're happy to help!