Students will be able to:
Challenge Level: Growing experience
This programming challenge is linked to the following lessons:
Create a program which asks the user to enter a number and checks if the number is odd or even. You should do this by keep subtracting 2 from your number until it is 0 or 1 (i.e. If it is 0 then the number is even and if it is 1 the number is odd). Make sure your program works for negative numbers as well.
Your program should display the outputs shown in this table for the given inputs provided:
|265||You entered an odd number!|
|0||You entered an even number!|
|-22||You entered an even number!|
Click on the green flag, enter the inputs provided in the “testing examples” to see the expected output of your program.
when green flag clicked ask [Enter a number:] and wait change [number v] by (-2)
if <(number) < > then end repeat until <<(number) = > or <(number) = >> end if <(number) = > then end if <(number) = > then end
say [You entered an odd number!] say [You entered an even number!]
set [number v] to  set [number v] to (answer) set [number v] to ((-1) * (number))
< < >,
< > >, or
< = >blocks under “Operators”.
< <> or <> >operation under “Operators” joins two boolean blocks so any one of them can be true to return true. If at least one of them is true, the block returns true. If neither of them are true, it returns false.