forked from sumedha3111/Python-for-Beginners
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshy no.py
More file actions
29 lines (17 loc) · 1.17 KB
/
shy no.py
File metadata and controls
29 lines (17 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#program to find whether a no. is shy no. or not
ch=1 #initialiing the choice variable with 1
while ch ==1:
s=0 #initializing sum of digits as 0
p=1 #initializing product of digits as 1
n=int(input("Enter a Number:")) #Taking input the user given no.
org=n # storing the original no. for further use
while n!=0 : #while loop until the number becomes 0
r=n%10 #finding the last digit of the number
n=n//10 #eliminating the last digit
s= s+r # finding the sum of the obtained digits
p=p*r # finding the product of the obtained digits
if s==p : #checking if the sum and product are equal or not
print(org,"is a shy number :)")
else :
print(org, "is not a Shy number :( ")
ch=int(input(" Wanna try another one?.... Press 1 if yes " ))