SlideShare a Scribd company logo
1 of 19
#printing natural nos and sum from 1 to 100 – while loop
#printing squares of odd nos fro 1 to 100
x=1
while x<=100:
print(x* x, end="t")
x+=2
print(" bye")
56 63 70 77 84 91 98
sum of the nos divisible by 7 from 1 to 100 is : 539
n!=n*(n-1)*(n-2)*(n-3)……..1
5!=5*4*3*2*1
4!=4*3*2*1
6!=6*5*4*3*2*1
1!=1
Factorial of an integer
enter a no 5
Factorial is 120
Factorial of an integer
Factorial explanation( 5! )
n=5
f=1 ,
n>0 True as 5>0
f=f*n=1*5=5
n=n-1=5-1=4
4>0 true
f=5*4=20
n=4-1=3
3>0 ,true
f=20*3=60
n=3-1=2
2>0 ,true
f=60*2=120
n=2-1=1
1>0 ,true
f=120*1=120
n=1-1=0
0>0 ,False
FIRST
2ND
3RD
4TH
5TH
120
Factorial of an integer
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
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
# 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
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
REVERSE OF A NO
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
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
PALINDROME NUMBER
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
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
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.
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&

More Related Content

Similar to 1 DEC LOOP REVISION.pptx

Maths formula by viveksingh698@gmail.com
Maths formula by viveksingh698@gmail.comMaths formula by viveksingh698@gmail.com
Maths formula by viveksingh698@gmail.com
vivek698
 
Arithmetic and geometric_sequences
Arithmetic and geometric_sequencesArithmetic and geometric_sequences
Arithmetic and geometric_sequences
Dreams4school
 
Pre-Algebra 4 1, 4-2
Pre-Algebra 4 1, 4-2Pre-Algebra 4 1, 4-2
Pre-Algebra 4 1, 4-2
Kathy Favazza
 
Delos-Santos-Analyn-M.-_Repoter-No.-1-Multiplication-and-Division-of-Polynomi...
Delos-Santos-Analyn-M.-_Repoter-No.-1-Multiplication-and-Division-of-Polynomi...Delos-Santos-Analyn-M.-_Repoter-No.-1-Multiplication-and-Division-of-Polynomi...
Delos-Santos-Analyn-M.-_Repoter-No.-1-Multiplication-and-Division-of-Polynomi...
polanesgumiran
 
Lesson 1.2 multiplication
Lesson 1.2 multiplicationLesson 1.2 multiplication
Lesson 1.2 multiplication
A V Prakasam
 
Fundamentals of AlgebraChu v. NguyenIntegral Exponents
Fundamentals of AlgebraChu v. NguyenIntegral ExponentsFundamentals of AlgebraChu v. NguyenIntegral Exponents
Fundamentals of AlgebraChu v. NguyenIntegral Exponents
DustiBuckner14
 
Two step equations
Two step equationsTwo step equations
Two step equations
mlabuski
 
Week 2.1 fractions dilek ozalp_5.31.2013
Week 2.1  fractions dilek ozalp_5.31.2013Week 2.1  fractions dilek ozalp_5.31.2013
Week 2.1 fractions dilek ozalp_5.31.2013
willa813
 

Similar to 1 DEC LOOP REVISION.pptx (20)

Maths formula by viveksingh698@gmail.com
Maths formula by viveksingh698@gmail.comMaths formula by viveksingh698@gmail.com
Maths formula by viveksingh698@gmail.com
 
Bisection
BisectionBisection
Bisection
 
Rational numbers 8 th std
Rational numbers 8 th stdRational numbers 8 th std
Rational numbers 8 th std
 
Math 5
Math 5 Math 5
Math 5
 
Arithmetic and geometric_sequences
Arithmetic and geometric_sequencesArithmetic and geometric_sequences
Arithmetic and geometric_sequences
 
Chapter 4.1 and 4.2
Chapter 4.1 and 4.2Chapter 4.1 and 4.2
Chapter 4.1 and 4.2
 
Number System2.pptx
Number System2.pptxNumber System2.pptx
Number System2.pptx
 
Maths T5 W1
Maths T5 W1Maths T5 W1
Maths T5 W1
 
5
55
5
 
Introduction to Recursion (Python)
Introduction to Recursion (Python)Introduction to Recursion (Python)
Introduction to Recursion (Python)
 
Pre-Algebra 4 1, 4-2
Pre-Algebra 4 1, 4-2Pre-Algebra 4 1, 4-2
Pre-Algebra 4 1, 4-2
 
Rational numbers
Rational numbersRational numbers
Rational numbers
 
Delos-Santos-Analyn-M.-_Repoter-No.-1-Multiplication-and-Division-of-Polynomi...
Delos-Santos-Analyn-M.-_Repoter-No.-1-Multiplication-and-Division-of-Polynomi...Delos-Santos-Analyn-M.-_Repoter-No.-1-Multiplication-and-Division-of-Polynomi...
Delos-Santos-Analyn-M.-_Repoter-No.-1-Multiplication-and-Division-of-Polynomi...
 
Lesson 1.2 multiplication
Lesson 1.2 multiplicationLesson 1.2 multiplication
Lesson 1.2 multiplication
 
The Ring programming language version 1.5.3 book - Part 69 of 184
The Ring programming language version 1.5.3 book - Part 69 of 184The Ring programming language version 1.5.3 book - Part 69 of 184
The Ring programming language version 1.5.3 book - Part 69 of 184
 
Fundamentals of AlgebraChu v. NguyenIntegral Exponents
Fundamentals of AlgebraChu v. NguyenIntegral ExponentsFundamentals of AlgebraChu v. NguyenIntegral Exponents
Fundamentals of AlgebraChu v. NguyenIntegral Exponents
 
Two step equations
Two step equationsTwo step equations
Two step equations
 
Recursion
RecursionRecursion
Recursion
 
Week 2.1 fractions dilek ozalp_5.31.2013
Week 2.1  fractions dilek ozalp_5.31.2013Week 2.1  fractions dilek ozalp_5.31.2013
Week 2.1 fractions dilek ozalp_5.31.2013
 
pdf_20221129_084739_0000.pptx
pdf_20221129_084739_0000.pptxpdf_20221129_084739_0000.pptx
pdf_20221129_084739_0000.pptx
 

Recently uploaded

1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 

Recently uploaded (20)

ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 

1 DEC LOOP REVISION.pptx

  • 1. #printing natural nos and sum from 1 to 100 – while loop
  • 2. #printing squares of odd nos fro 1 to 100 x=1 while x<=100: print(x* x, end="t") x+=2 print(" bye")
  • 3. 56 63 70 77 84 91 98 sum of the nos divisible by 7 from 1 to 100 is : 539
  • 5. enter a no 5 Factorial is 120 Factorial of an integer
  • 6. Factorial explanation( 5! ) n=5 f=1 , n>0 True as 5>0 f=f*n=1*5=5 n=n-1=5-1=4 4>0 true f=5*4=20 n=4-1=3 3>0 ,true f=20*3=60 n=3-1=2 2>0 ,true f=60*2=120 n=2-1=1 1>0 ,true f=120*1=120 n=1-1=0 0>0 ,False FIRST 2ND 3RD 4TH 5TH 120
  • 7. Factorial of an integer
  • 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&