64. Python Program to find the Sum of Even and Product of Odd digits of given 6 digit Number.
How does this program work?
- This program is used to find out the Sum of Even and Product of Odd digits in the given 6 digit Number using Python.
- In this program odd and even 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 zero, the number is even then sum will be executes else the number is odd then product will be executed by using given logic.
Here is the code
n = int(input("Enter a six digit number: "))
a = 0
c = 1
if(n > 99999):
while n > 0:
b = n % 10
if(b % 2 == 0 ):
a += b
else:
c *= b
n//=10
print("Sum of even digits: ", a)
print("Product of odd digits ", c)
else:
print("Not a six digit number")