Check Even and Odd Number in Python

Hi Guy's , Here is the article to check even and odd numbers in python programming.
we can check even and odd numbers in python by many ways but best way we should check by using if else statement.
if else statement check condition first . if condition true then if part of block execute . if condition false then else part of block 
run. Let's see the Program.



Code Explanation :
n = int (input ('Enter Any Number : ')) : At here " Enter Any Number : " that display into output screen. since here i am using input method so whatever we enter that accept into string and after applying int typecasting that convert 
into integer and store value into n. next line if n % 2 == 0: Modulus operator return remainder values suppose user enter 9 then 9%2 that return 1
now check 1 == 0 condition false then else block execute and print 9 Number is Odd.

Example 2 :

Happy Coding .... Thanks.
Previous
Next Post »

1 comments:

Click here for comments
Unknown
admin
February 15, 2020 at 2:33 AM ×

Wow, nice

Congrats bro Unknown you got PERTAMAX...! hehehehe...
Reply
avatar