Editor

Even or Odd Checker

Beginner · Write the code · from Python Numbers: Integers, Floats, and Math You'll Actually Use

From the lesson: Python Numbers: Integers, Floats, and Math You'll Actually Use

You're splitting a restaurant bill with three friends. The total is $85. How much does each person owe? You grab your phone calculator, but a Python programmer just types 85 / 4 and gets the answer instantly.

Read the lesson

Use the modulo operator (%) to check if a number is even or odd.

A variable number is given with the value 37. Print the result in this exact format:

37 is odd

If the number were even (like 42), the output would be:

42 is even
number = 37
# Use modulo to check if number is even or odd
# Print: "{number} is even" or "{number} is odd"

More Numbers exercises

All Python exercises · 50 practice problems · Python Fundamentals quiz