Product of Digits in Python

Hi Programmers, Here is the article to find product of digits of numbers using python programming. That's important program for python beginners. Let's see the code.
Code Explanation :

mul = 1 :- First i initialize mul integer variable with 1.
n = int(input("Enter Any Positive Number : ")) :- Enter Any Positive Number : that display output screen. now enter value
accept into string then due to typecasting that convert into integer.
while n > 0  :- now control transfer to while loop, if condition true then while loop continue.
k = int (n % 10) :-  if user enter 345. 345%10=5 and typecasting to convert float to int.
n = int (n / 10 ) :- 345 / 10 = 34. and due to typecasting decimal values convert into integer.
mul = mul * k  :- mul = 1 and k = 5, multiply. like this loop continue until false.
print("multiplication of Digits of Number = ",mul) :- when while loop exit then print "multiplication of Digits of Number =" and value of mul
into output screen.
Happy Coding...Thanks.
Newest
Previous
Next Post »