Hello World!!! It’s JITHU….. Welcome back to the day-7 of your programming life. As you know that programming is the key skill nowadays, But why only python as it simple and good for the beginners, That’s it??? Not really Because it consists of a lot of rich libraries that make our work a lot simpler.OK let me stop this and dive into our DAY-7 Tutorial.
Welcome Back Wizards!!!! Let’s continue the Session-2 of the Control statements…..
3] Iterative Control Statements:
What is Loop?
Loop is a continuous process that occurs in a repetitive manner until the condition is satisfied. Here the statements are executed in a sequential manner until the condition is proved.
Different Types of loops in python:
1] For loop.
3]Break and Continue.
There are only for loops let me wrap it know in this… Firstly.
Python is normal English based language, so it is used most popularly. when we will use FOR ok I will tell you FOR, example Yeap you got it now we used it in the same manner if I want to extract each character in my spelling here I am using For loop.
Here I used “x” as a variable that stores my every character of my name. “For” as an Iterator, “in” as an operator that is used to check present in the given string, and finally “Jithu stark” is an Iterable.
The complete statement (for x in “Jithu stark”) is an iteration.
Syntax: for var_name in sequence:
It generates lists containing arithmetic progression and returns the list of integers. There are 3 types of Ranges:
Let me complete this with one example each,
Here it generates a sequence of numbers from 0 to a, excluding a, and incrementing by 1.
Syntax: for <variable> in range(<number>):
Here range(5) excluding the value 5, in “Python the indexing starts from 0”
Here it generates a sequence of numbers from a to b, excluding b, and incrementing by 1.
Syntax: for <variable> in range(<start_number>,<end_number>):
Here it generates a sequence of numbers from a to b, excluding b, and incrementing by c.
Syntax: for <variable> in range(<start_number>,<end_number>,<step>):
Actually it breaks the program at a specific condition.
Here when num == 4, then the process has been broken so, only the 1st three numbers have been printed.
Here the condition is Broken at a specific region then, later it continues at the next level.
It is used to execute no.of statements until the end of the condition is true, if the condition is false the control will be out of the loop.
EXTRA SALT and PEPPER:
What is the difference between COMMENTS and PASS?
Comments are the non-executable Statements, While the Pass is an executable statement But NO OPERATION(NOP).