I can use some help on the even or odd practice. How does one declare an even to compare a random number to? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

I can use some help on the even or odd practice. How does one declare an even to compare a random number to?

Even or odd practice lesson 14.2

14th Feb 2021, 8:20 AM
Michelle Davis
Michelle Davis - avatar
5 Answers
+ 3
Could you maybe add the relevant challenge description or go into more detail of what you have to do? Without pro, many can't access the task, and I'm afraid I am a bit confused by your question. Are you supposed to evaluate whether a (random) number is even or odd?
14th Feb 2021, 8:25 AM
Shadow
Shadow - avatar
+ 3
Yes, you will want to use simple maths for that one. The basic idea is that when you divide a number by two, even numbers will have a remainder of zero, while odd numbers have a non-zero remainder. Does that already give you an idea?
14th Feb 2021, 8:31 AM
Shadow
Shadow - avatar
+ 1
I know the code I need except for the "even" to compare the input to.
14th Feb 2021, 8:21 AM
Michelle Davis
Michelle Davis - avatar
0
Yes shadow. I am required to take user input (random number) and output (print) even if the number is even and odd if it is odd. I know how to do every part except compare a random number to an unspecified variable to determine whether it is even or odd. Is this a math issue I am missing or what?
14th Feb 2021, 8:29 AM
Michelle Davis
Michelle Davis - avatar
0
Yes it does!! Thanks. I was not thinking division. I was trying addition. Duh!! Thank you.
14th Feb 2021, 8:32 AM
Michelle Davis
Michelle Davis - avatar