Python Program to Check Whether a Number is Even or Odd – Programming, Pseudocode Example, C# Programming Example
Python 3

Python Program to Check Whether a Number is Even or Odd

In this example, you will learn to check whether a number entered by the user is even or odd.

In the program, the integer entered by the user is stored in the variable num.

Then, whether num is perfectly divisible by 2 or not is checked using the modulus % operator.

If the number is perfectly divisible by 2, test expression number%2 == 0 evaluates to 1 (true). This means the number is even.

However, if the test expression evaluates to 0 (false), the number is odd.

Python Code:

Output:

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.