Check for odd/even numbers using “mod” operation

Challenge Level: Growing experience

Learning outcomes

Students will be able to:

Requirement:

Create a program which asks the user to enter a number and checks if the number is odd or even. Use the “mod” operation for this challenge.

Testing examples:

Your program should display the outputs shown in this table for the given inputs provided;

Input Output
265 You entered an odd number!
0 You entered an even number!
-22 You entered an even number!

Languages

Scratch

What it should look like

Click on the green flag to see the expected output of your program.

Recommended blocks
whenclickedaskEnter a number:andwaitsetnumbertoanswersayYou entered an even number!sayYou entered an odd number!ifnumbermod2=0thenelse
Hints
  • To find out if a number is even or odd, use the “mod” operation to find the remainder after dividing that number by two. If the remainder is zero the number is even (the mod operation under “Operators” script returns the remainder from division of two numbers. For example: 17mod3 2)

Show Scratch solution

Python
Block-based