SlideShare uma empresa Scribd logo
1 de 14
Loops in Python
Programming Language
Submitted By:
Maghfoor Ahmad
MCA TYC 2nd Sem
Roll No: 27512100052
Introduction
Sometimes, there is a need to tell a computer
to repeat an action without writing separate
code for each repetition. In programming, this
concept is called loops.
Loops
A loop can be used to tell a program to execute
statements repeatedly. Or we can say that a loop
repeatedly executes the same set of instructions
until a termination condition is met.
Loops changes the control flow of program
that’s why they are also called Control Structure.
Why is it important?
Suppose that you need to display a
string (e.g., Good Morning! ) a
hundred times.
It would be tedious to write this
statement a hundred times:
print(“Good Morning!“)
print(“Good Morning!“)
print(“Good Morning!“)
.
.
.
.
print(“Good Morning!“)
Fortunately, We have loops. Using a loop control statement, you simply tell the
computer to display a string a hundred times without having to code the print
statement a hundred times, as follows:
for i in range (0,100):
print(“Good Morning!")
This will write the Good Morning! hundred times as follows:
Good Morning!
Good Morning!
Good Morning!
Good Morning!
Good Morning!
.
.
.
Good Morning!
Good Morning!
Output:
Python programming language provides
following types of loops to handle looping
requirements. They are:
● While Loop
● For Loop
● Nested Loop
Let’s understand each of the loops
mentioned above.
Type of Loops
While Loop
A while loop statement in Python programming language repeatedly executes a
block of statement as long as a given condition is true.
while expression:
statement(s)
Here, statement(s) may be a single statement
or a block of statements. The expression may
be any condition.
The loop iterates while the condition is true.
When the condition becomes false, program
control passes to the line immediately
following the loop.
The syntax of a while loop in Python
programming language is:
Source: Tutorials Point
Example of while Loop
i=1
#The while loop will iterate until condition becomes false.
While(i<=10):
print(i)
i=i+1
Program to print 1 to 10 using while loop
1
2
3
4
5
6
7
8
9
10
Output:
for Loop
A for loop is used for iterating over a sequence (that is either a range, a list, a
tuple, a dictionary, a set, or a string)
for iterating_var in sequence:
statement(s)
Here, the iterating_var can be either an iterable
or a sequence item. If it is an index, we use
the range() function instead of the sequence.
Otherwise, we can mention the sequence.
For each item in sequence, the statements block
will be executed until there are no item. After no
items left in sequence the control will be
transferred to code following the loop.
The syntax of a for loop in Python is:
Source: Tutorials Point
Example of for Loop
fruits = ["apple", "banana", "cherry"]
for x in fruits:
print(x)
LIST: Program to print each fruit in a fruit list:
apple
banana
cherry
Output:
for i in range(0,3):
print("Hello")
Range: Program to print “Hello” 3 times:
Hello
Hello
Hello
Output:
Nested Loops
A nested loop is a loop inside the body of a loop. It can be for loop inside a for loop
or while inside a while loop. It can also be for inside a while loop and vice versa.
#Outer Loop
for iterating_var1 in sequence1:
#Inner Loop
for iterating_var2 in sequence2:
statement(s)
For each iteration, the outer loop will executes once and the inner loop will
executes till completion.
The nested loops can be understood by following examples:
● Printing multiplication table of numbers (1 to 3)
● Printing a matrix of 3 column and 2 rows
The syntax of a nested loop in Python programming language is:
#Outer Loop
while expression:
#Inner Loop
while expression:
statement(s)
statement(s)
Example of Nested while Loop
i=1
while i<=3: #Outer Loop
j=1
while j<=5: #Inner Loop
print i,"*",j,'=',i*j
j+=1 #Inner Loop Ends
i+=1
print "n" #Outer Loop Ends
Printing multiplication table up to 5 of numbers (1 to 3)
1 * 1 = 1 2 * 1 = 2 3 * 1 = 3
1 * 2 = 2 2 * 2 = 4 3 * 2 = 6
1 * 3 = 3 2 * 3 = 6 3 * 3 = 9
1 * 4 = 4 2 * 4 = 8 3 * 4 = 12
1 * 5 = 5 2 * 5 = 10 3 * 5 = 15
Output:
Example of Nested for Loop
for row in range(2):
for col in range(3):
print("1", end= " ")
print("n")
Printing a matrix of 3 column and 2 rows
1 1 1
1 1 1
Output:
while Loop for Loop
1.
While loop is used when the
number of iteration is not known.
For loop is used when the
number of iteration is known.
2.
It shows an error if no condition is
given.
It iterates infinite time, if no
condition is given.
3.
Initialization, condition checking,
and iteration statements are
written at the top.
Only initialization and condition
checking is written at the top
Key Differences
Thankyou!
1. Reddy, Priyanka. “Introduction to Loops in Coding”. Codingal, 2021.
https://www.codingal.com/blog/coding-for-kids/loops-in-programming/
2. Ansari, Rumman. “C Programming Loop Introduction”. Atnyla, 2019.
https://www.atnyla.com/tutorial/loop-introduction-in-c/1/194
3. Gupta, Raghav, Nishant, Priyanka Gupta, and Naveen Sharma. Computational
Problem Solving With Programming In Python. Kalyani Publishers, 2019.
4. “Pyhton - Loops”. Tutorials Point.
https://www.tutorialspoint.com/python/python_loops.htm
5. “Pyhton while Loop Statements”. Tutorials Point.
https://www.tutorialspoint.com/python/python_loops.htm
6. “Python For Loops”. W3 Schools.
https://www.w3schools.com/python/python_for_loops.asp
7. Vishal. “Nested Loops in Python”. Pynative, 2021.
https://pynative.com/python-nested-loops/#h-what-is-a-nested-loop-in-python
Bibliography

Mais conteúdo relacionado

Mais procurados (20)

Strings in C
Strings in CStrings in C
Strings in C
 
C string
C stringC string
C string
 
Programming in c Arrays
Programming in c ArraysProgramming in c Arrays
Programming in c Arrays
 
Python programming : Strings
Python programming : StringsPython programming : Strings
Python programming : Strings
 
Introduction to Python
Introduction to Python Introduction to Python
Introduction to Python
 
Datatypes in python
Datatypes in pythonDatatypes in python
Datatypes in python
 
Pointers in c - Mohammad Salman
Pointers in c - Mohammad SalmanPointers in c - Mohammad Salman
Pointers in c - Mohammad Salman
 
Exception handling c++
Exception handling c++Exception handling c++
Exception handling c++
 
Python Flow Control
Python Flow ControlPython Flow Control
Python Flow Control
 
Polymorphism in c++(ppt)
Polymorphism in c++(ppt)Polymorphism in c++(ppt)
Polymorphism in c++(ppt)
 
Function Pointer
Function PointerFunction Pointer
Function Pointer
 
Array in c++
Array in c++Array in c++
Array in c++
 
6-Python-Recursion PPT.pptx
6-Python-Recursion PPT.pptx6-Python-Recursion PPT.pptx
6-Python-Recursion PPT.pptx
 
Templates in C++
Templates in C++Templates in C++
Templates in C++
 
Loops in Python
Loops in PythonLoops in Python
Loops in Python
 
Python exception handling
Python   exception handlingPython   exception handling
Python exception handling
 
Looping statements in C
Looping statements in CLooping statements in C
Looping statements in C
 
Operators and expressions in C++
Operators and expressions in C++Operators and expressions in C++
Operators and expressions in C++
 
Data types in python
Data types in pythonData types in python
Data types in python
 
Java Arrays
Java ArraysJava Arrays
Java Arrays
 

Semelhante a Loops in Python.pptx

Python Decision Making And Loops.pdf
Python Decision Making And Loops.pdfPython Decision Making And Loops.pdf
Python Decision Making And Loops.pdfNehaSpillai1
 
While-For-loop in python used in college
While-For-loop in python used in collegeWhile-For-loop in python used in college
While-For-loop in python used in collegessuser7a7cd61
 
loopingstatementinpython-210628184047 (1).pdf
loopingstatementinpython-210628184047 (1).pdfloopingstatementinpython-210628184047 (1).pdf
loopingstatementinpython-210628184047 (1).pdfDheeravathBinduMadha
 
Loops in c language
Loops in c languageLoops in c language
Loops in c languagetanmaymodi4
 
Loops in c language
Loops in c languageLoops in c language
Loops in c languageTanmay Modi
 
Intro to OpenMP
Intro to OpenMPIntro to OpenMP
Intro to OpenMPjbp4444
 
Bikalpa_Thapa_Python_Programming_(Basics).pptx
Bikalpa_Thapa_Python_Programming_(Basics).pptxBikalpa_Thapa_Python_Programming_(Basics).pptx
Bikalpa_Thapa_Python_Programming_(Basics).pptxBikalpa Thapa
 
Python programing
Python programingPython programing
Python programinghamzagame
 
Loops IN COMPUTER SCIENCE STANDARD 11 BY KR
Loops IN COMPUTER SCIENCE STANDARD 11 BY KRLoops IN COMPUTER SCIENCE STANDARD 11 BY KR
Loops IN COMPUTER SCIENCE STANDARD 11 BY KRKrishna Raj
 
Looping statement in python
Looping statement in pythonLooping statement in python
Looping statement in pythonRaginiJain21
 
Looping Statements and Control Statements in Python
Looping Statements and Control Statements in PythonLooping Statements and Control Statements in Python
Looping Statements and Control Statements in PythonPriyankaC44
 

Semelhante a Loops in Python.pptx (20)

Python Decision Making And Loops.pdf
Python Decision Making And Loops.pdfPython Decision Making And Loops.pdf
Python Decision Making And Loops.pdf
 
While-For-loop in python used in college
While-For-loop in python used in collegeWhile-For-loop in python used in college
While-For-loop in python used in college
 
While loop
While loopWhile loop
While loop
 
Control structures pyhton
Control structures  pyhtonControl structures  pyhton
Control structures pyhton
 
Python Loop
Python LoopPython Loop
Python Loop
 
Iteration
IterationIteration
Iteration
 
Loops c++
Loops c++Loops c++
Loops c++
 
loopingstatementinpython-210628184047 (1).pdf
loopingstatementinpython-210628184047 (1).pdfloopingstatementinpython-210628184047 (1).pdf
loopingstatementinpython-210628184047 (1).pdf
 
Loops in c language
Loops in c languageLoops in c language
Loops in c language
 
Loops in c language
Loops in c languageLoops in c language
Loops in c language
 
Intro to OpenMP
Intro to OpenMPIntro to OpenMP
Intro to OpenMP
 
lecture 2.pptx
lecture 2.pptxlecture 2.pptx
lecture 2.pptx
 
Bikalpa_Thapa_Python_Programming_(Basics).pptx
Bikalpa_Thapa_Python_Programming_(Basics).pptxBikalpa_Thapa_Python_Programming_(Basics).pptx
Bikalpa_Thapa_Python_Programming_(Basics).pptx
 
Matlab Script - Loop Control
Matlab Script - Loop ControlMatlab Script - Loop Control
Matlab Script - Loop Control
 
Python programing
Python programingPython programing
Python programing
 
Python Control structures
Python Control structuresPython Control structures
Python Control structures
 
Loops IN COMPUTER SCIENCE STANDARD 11 BY KR
Loops IN COMPUTER SCIENCE STANDARD 11 BY KRLoops IN COMPUTER SCIENCE STANDARD 11 BY KR
Loops IN COMPUTER SCIENCE STANDARD 11 BY KR
 
Python_Module_2.pdf
Python_Module_2.pdfPython_Module_2.pdf
Python_Module_2.pdf
 
Looping statement in python
Looping statement in pythonLooping statement in python
Looping statement in python
 
Looping Statements and Control Statements in Python
Looping Statements and Control Statements in PythonLooping Statements and Control Statements in Python
Looping Statements and Control Statements in Python
 

Último

Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfChris Hunter
 
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.pdfQucHHunhnh
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.MateoGardella
 
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 . pdfQucHHunhnh
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docxPoojaSen20
 
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 17Celine George
 
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.pptxDenish Jangid
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfSanaAli374401
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docxPoojaSen20
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
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.pptxAreebaZafar22
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 

Último (20)

Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.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
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.
 
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
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
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
 
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
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
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
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 

Loops in Python.pptx

  • 1. Loops in Python Programming Language Submitted By: Maghfoor Ahmad MCA TYC 2nd Sem Roll No: 27512100052
  • 2. Introduction Sometimes, there is a need to tell a computer to repeat an action without writing separate code for each repetition. In programming, this concept is called loops. Loops A loop can be used to tell a program to execute statements repeatedly. Or we can say that a loop repeatedly executes the same set of instructions until a termination condition is met. Loops changes the control flow of program that’s why they are also called Control Structure.
  • 3. Why is it important? Suppose that you need to display a string (e.g., Good Morning! ) a hundred times. It would be tedious to write this statement a hundred times: print(“Good Morning!“) print(“Good Morning!“) print(“Good Morning!“) . . . . print(“Good Morning!“)
  • 4. Fortunately, We have loops. Using a loop control statement, you simply tell the computer to display a string a hundred times without having to code the print statement a hundred times, as follows: for i in range (0,100): print(“Good Morning!") This will write the Good Morning! hundred times as follows: Good Morning! Good Morning! Good Morning! Good Morning! Good Morning! . . . Good Morning! Good Morning! Output:
  • 5. Python programming language provides following types of loops to handle looping requirements. They are: ● While Loop ● For Loop ● Nested Loop Let’s understand each of the loops mentioned above. Type of Loops
  • 6. While Loop A while loop statement in Python programming language repeatedly executes a block of statement as long as a given condition is true. while expression: statement(s) Here, statement(s) may be a single statement or a block of statements. The expression may be any condition. The loop iterates while the condition is true. When the condition becomes false, program control passes to the line immediately following the loop. The syntax of a while loop in Python programming language is: Source: Tutorials Point
  • 7. Example of while Loop i=1 #The while loop will iterate until condition becomes false. While(i<=10): print(i) i=i+1 Program to print 1 to 10 using while loop 1 2 3 4 5 6 7 8 9 10 Output:
  • 8. for Loop A for loop is used for iterating over a sequence (that is either a range, a list, a tuple, a dictionary, a set, or a string) for iterating_var in sequence: statement(s) Here, the iterating_var can be either an iterable or a sequence item. If it is an index, we use the range() function instead of the sequence. Otherwise, we can mention the sequence. For each item in sequence, the statements block will be executed until there are no item. After no items left in sequence the control will be transferred to code following the loop. The syntax of a for loop in Python is: Source: Tutorials Point
  • 9. Example of for Loop fruits = ["apple", "banana", "cherry"] for x in fruits: print(x) LIST: Program to print each fruit in a fruit list: apple banana cherry Output: for i in range(0,3): print("Hello") Range: Program to print “Hello” 3 times: Hello Hello Hello Output:
  • 10. Nested Loops A nested loop is a loop inside the body of a loop. It can be for loop inside a for loop or while inside a while loop. It can also be for inside a while loop and vice versa. #Outer Loop for iterating_var1 in sequence1: #Inner Loop for iterating_var2 in sequence2: statement(s) For each iteration, the outer loop will executes once and the inner loop will executes till completion. The nested loops can be understood by following examples: ● Printing multiplication table of numbers (1 to 3) ● Printing a matrix of 3 column and 2 rows The syntax of a nested loop in Python programming language is: #Outer Loop while expression: #Inner Loop while expression: statement(s) statement(s)
  • 11. Example of Nested while Loop i=1 while i<=3: #Outer Loop j=1 while j<=5: #Inner Loop print i,"*",j,'=',i*j j+=1 #Inner Loop Ends i+=1 print "n" #Outer Loop Ends Printing multiplication table up to 5 of numbers (1 to 3) 1 * 1 = 1 2 * 1 = 2 3 * 1 = 3 1 * 2 = 2 2 * 2 = 4 3 * 2 = 6 1 * 3 = 3 2 * 3 = 6 3 * 3 = 9 1 * 4 = 4 2 * 4 = 8 3 * 4 = 12 1 * 5 = 5 2 * 5 = 10 3 * 5 = 15 Output:
  • 12. Example of Nested for Loop for row in range(2): for col in range(3): print("1", end= " ") print("n") Printing a matrix of 3 column and 2 rows 1 1 1 1 1 1 Output: while Loop for Loop 1. While loop is used when the number of iteration is not known. For loop is used when the number of iteration is known. 2. It shows an error if no condition is given. It iterates infinite time, if no condition is given. 3. Initialization, condition checking, and iteration statements are written at the top. Only initialization and condition checking is written at the top Key Differences
  • 14. 1. Reddy, Priyanka. “Introduction to Loops in Coding”. Codingal, 2021. https://www.codingal.com/blog/coding-for-kids/loops-in-programming/ 2. Ansari, Rumman. “C Programming Loop Introduction”. Atnyla, 2019. https://www.atnyla.com/tutorial/loop-introduction-in-c/1/194 3. Gupta, Raghav, Nishant, Priyanka Gupta, and Naveen Sharma. Computational Problem Solving With Programming In Python. Kalyani Publishers, 2019. 4. “Pyhton - Loops”. Tutorials Point. https://www.tutorialspoint.com/python/python_loops.htm 5. “Pyhton while Loop Statements”. Tutorials Point. https://www.tutorialspoint.com/python/python_loops.htm 6. “Python For Loops”. W3 Schools. https://www.w3schools.com/python/python_for_loops.asp 7. Vishal. “Nested Loops in Python”. Pynative, 2021. https://pynative.com/python-nested-loops/#h-what-is-a-nested-loop-in-python Bibliography