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 lessonUse 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 oddIf the number were even (like 42), the output would be:
42 is evennumber = 37
# Use modulo to check if number is even or odd
# Print: "{number} is even" or "{number} is odd"
More Numbers exercises
- Calculate the Total CostBeginner
- Fix the Bug: Wrong DivisionBeginner
- Fahrenheit to Celsius ConverterBeginner
- Predict the OutputBeginner
- Compound Interest CalculatorBeginner
All Python exercises · 50 practice problems · Python Fundamentals quiz