8. Output
enter a no 5
Factorial of 5 is 120
>>> ================================ RESTART
================================
>>>
enter a no 4
Factorial of 4 is 24
>>> ================================ RESTART
================================
>>>
enter a no 7
Factorial of 7 is 5040
9. Factorial explanation( 4! )
n=4
f=1
for i in range(n,0,-1)
f=f* i=1*4=4
i=i-1= 4-1= 3
f=4*3=12
i=3-1=2
f=12*2=24
i=2-1=1
f=24*1=24
i=1-1=0
FIRST
2ND
3RD
4TH
24
10. # To find the sum of digits in a no
Give an integer no 345
sum of the of digits = 12
>>> ================================ RESTART
================================
>>>
Give an integer no 1234
sum of the of digits = 10
11. SUM OF DIGIT OF 345
Give an integer no x= 345
s=r=0
345>0 true
r=345%10=5
s=s + r=0+5=5
x=345//10=34
3>0 true
3%10=3
s=s + r=9+3=12
x=3//10=0
x=0>0 False
FIRST 3rd
34>0 true
r=34%10=4
s=s+r=5+4=9
x=34//10=3
2nd 12
13. REVERSE OF DIGIT OF 345
Give an integer no x=345
s=r=0
345>0 true
r=345%10=5
s=s*10 + r=0+5=5
x=345//10=34
3>0 true
3%10=3
s=s*10 + r=54*10+3=543
x=3//10=0
x=0>0 False
FIRST
3rd
34>0 true
r=34%10=4
s=s*10+r=5*10+4=54
x=34//10=3
2nd 543
14. Give an integer no 345
Reverse no is 543
>>> ================================ RESTART
================================
>>>
Give an integer no 123
Reverse no is 321
>>> ================================ RESTART
================================
>>>
Give an integer no 121
Reverse no is 121
16. output
Give an integer no 345 ------x
345 is not a palindrome number
S --- 543 , y----345
>>>
================================
RESTART
================================
>>>
Give an integer no 131
S --- 131 , y----131
131 is a palindrome number
17. PALINDROME CHECK OF DIGIT OF 345
Give an integer no x=345
s=r=0
345>0 true
r=345%10=5
s=s*10 + r=0+5=5
x=345//10=34
3>0 true
3%10=3
s=s*10 + r=54*10+3=543
x=3//10=0
x=0>0 False
FIRST
3rd
34>0 true
r=34%10=4
s=s*10+r=5*10+4=54
x=34//10=3
2nd 543
345
y s
18. Jump Statements – break &
continue
break statement in python is used to
terminate the containing loop for any
given condition. Program resumes from
the statement immediately after the
loop
Continue statement in python is used to
skip the statements below continue
statement inside loop and forces the
loop to continue with next value.
19. Example –
break
for i in range(1,20):
if i % 6 == 0:
break
print(i)
print(“Loop Over”)
The above code produces output
1
2
3
4
5
Loop Over
when the value of i reaches to 6 condition will becomes
True and loop will end and messageV“IN
LOoDo
K
U
p
M
A
O
R
V
vE
R
eM
rA
”,
P
G
wT
(
iC
llS
)
,
bK
V
eO
pE
F
rK
iA
nN
tP
eU
R
d&