0
What is a loop? How to create it? What is its purpose?
5 Answers
+ 6
APARNA MURALEEDHARAN M K ,
here are 2 links for tutorials from sololearn:
https://www.sololearn.com/learn/JUMP_LINK__&&__Python__&&__JUMP_LINK/2435/?ref=app
https://www.sololearn.com/learn/Python/2281/?ref=app
+ 2
APARNA MURALEEDHARAN M K Welcome to Sololearn!
You can start learning Python here, and it will lead you into understanding loops:
https://www.sololearn.com/Course/Python-for-Beginners/?ref=app
Loops are what give computers an advantage over human brains. Computers can repeat a set of instructions over and over again many times faster than we can, which is how computers make us more productive.
A loop of code will have a conditional instruction that determines when to stop repeating. The condition might be to repeat the loop for a specified number of times, or to keep repeating while a condition is true. Python supports those two types of loops by supplying "for" and "while" statements. They are explained further in the lessons linked in Lothar's answer. But you should study the Python lessons from the beginning.
+ 1
Continue your course and you'll find out. Or:
https://www.wikihow.com/Search-the-Internet
+ 1
If you know loop then u need to read two more lines have you read .?
+ 1
Python programming language provides following types of loops to handle looping requirements. Python provides three ways for executing the loops. While all the ways provide similar basic functionality, they differ in their syntax and condition checking time.
While Loop:
In python, while loop is used to execute a block of statements repeatedly until a given a condition is satisfied. And when the condition becomes false, the line immediately after the loop in program is executed.
Syntax :
while expression:
statement(s)
A for loop is used for iterating over a sequence (that is either a list, a tuple, a dictionary, a set, or a string).
This is less like the for keyword in other programming languages, and works more like an iterator method as found in other object-orientated programming languages.
With the for loop we can execute a set of statements, once for each item in a list, tuple, set etc.
Print each fruit in a fruit list:
fruits = ["apple", "banana", "cherry"]
for x in fruits:
print(x)