-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathday_05whileloop.py
More file actions
106 lines (65 loc) · 1.5 KB
/
day_05whileloop.py
File metadata and controls
106 lines (65 loc) · 1.5 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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#----------------------------------------
#day_5whileloop
#----------------------------------------
#1.Reverse of a number
n=int(input("Enter a number:"))
rev=0
while(n>0):
digit=n%10
rev=rev*10+digit
n//=10
print("Reverse of the given number is",rev)
#----------------------------------------
#2.Sum of Digits
num=int(input("Enter a number:"))
sum_diguts=0
while num>0:
digit=num%10
sum_digits += digit
num//=10
print("Sum of all digits",sum_digits")
#---------------------------------------
#3.Print 1 to N numbers
n = int(input("Enter n:"))
i=1
while i<=n:
print(i)
i+=1
#----------------------------------------
#4.Multiplication Table
n=int(input("Enter n:"))
i=1
while i<=10:
print(n,"x",i,"=",n*i)
i+=1
#----------------------------------------
#5.Palindrome Check
num=int(input("Enter a number:"))
org=num
rev=0
while n>0:
digit=num%10
rev=rev*10+digit
num//=10
if (org==rev):
print("The entered number is a Palindrome.")
else:
print("The entered number is not a Palindrome.")
#---------------------------------------
#6.Password Checker
passw=""
while (passw!="hihi%22%"):
passw=input("Enter Password:")
print("Successful")
#----------------------------------------
#7. Number Guessing Game
secret=12
guess=0
while guess!=secret :
guess = int(input("Enter a number:"))
if(guess>secret):
print("Larger number")
elif(guess<secret):
print("Smaller number")
print("You're Right!")
#---------------------------------------