How to make a program differentiate even and odd numbers in python

Asked

Viewed 4,307 times

0

hello good night I would like to learn how to make a program differentiate odd pairs numbers

I have to learn about what ?

  • 3

    First, I recommend you learn to use the site correctly to avoid any possible embarrassment. You can do this very easily by accessing the [tour]. The tour gives you a good overview of how the site works and, if you want more detailed information, go to [help].

  • 3

    Secondly, you must study, if you do not know, what is the mathematical definition of even and odd numbers, that is, how to differentiate mathematically the two. After that, look to learn about mathematical operators and numerical types and control structures.

1 answer

2


You need to use an operator called module, because it will divide the number, and return you the rest, so if a number divided by 2 returns zero, it will be even otherwise it will be odd.

example:

4 % 2 == 0 the return of this operation will be 0 or the number is even

5 % 2 == 0 in this case the return will be 1 or the number is odd

  • thank you mikaellemos033

Browser other questions tagged

You are not signed in. Login or sign up in order to post.