DIR Return Create A Forum - Home
---------------------------------------------------------
Stack First Status
HTML https://casadecode.createaforum.com
---------------------------------------------------------
*****************************************************
DIR Return to: Programming Problems & Solutions
*****************************************************
#Post#: 16--------------------------------------------------
Python Program to Check if a Number is Odd or Even
DIR By: admin
Date: May 24, 2021, 5:14 am
---------------------------------------------------------
In this example, you will learn to check whether a number
entered by the user is even or odd.
A number is even if it is perfectly divisible by 2. When the
number is divided by 2, we use the remainder operator % to
compute the remainder. If the remainder is not zero, the number
is odd.
--- Code ---
# Python program to check if the input number is odd or even.
# A number is even if division by 2 gives a remainder of 0.
# If the remainder is 1, it is an odd number.
num = int(input("Enter a number: "))
if (num % 2) == 0:
print("{0} is Even".format(num))
else:
print("{0} is Odd".format(num))
--- End Code ---
Output:
--- Code ---
Enter a number: 43
43 is Odd
--- End Code ---
#Post#: 18--------------------------------------------------
Re: Python Program to Check if a Number is Odd or Even
DIR By: nasir22
Date: May 30, 2021, 2:00 am
---------------------------------------------------------
Wow.
#Post#: 19--------------------------------------------------
Re: Python Program to Check if a Number is Odd or Even
DIR By: admin
Date: May 30, 2021, 2:08 am
---------------------------------------------------------
Thanks :)
#Post#: 20--------------------------------------------------
Re: Python Program to Check if a Number is Odd or Even
DIR By: nasir22
Date: May 30, 2021, 2:10 am
---------------------------------------------------------
Welcome
#Post#: 40--------------------------------------------------
Re: Python Program to Check if a Number is Odd or Even
DIR By: admin
Date: May 31, 2021, 10:49 am
---------------------------------------------------------
;D
*****************************************************
Page 1 of 1