Share 2-Control Statements
Share 2-Control Statements
1. If
2. If – else
3. If-elif-else statements
4. Nested if statements
• Iterative Control Statements
1. While loop
2. For loop
• Break, continue and pass statements
Control Statements
Control statements in python are used to control
1. If
2. If – else
3. If-elif-else statements
4. Nested if statements
If Statement
If-else Statement
If-elif-else Statement
Nested if Statement
Iterative/looping
Statements
used to repeat the execution of a list of statements.
1. While loop
2. For loop
Nested loops
While Statement
For Statement
Range() funtion
It is a built-in function.
Used to iterate over a sequence of numbers.
Syn:- range(begin,start,[step])
[step]can be either positive or negative value
Ex:- Factorial of number
Nested loop
break/continue/pass
Statements
1. Break: (Terminates the loop and transfers execution to
the statement immediately following the loop)
2. Continue: (Stop the current iteration and continues
the with next one)
3. Pass: (specifies ‘null’ operation or No operation)
break Statement
1. It breaks the current loop
2. Break and continue statements outside a loop
causes an error.
Continue Statement
Skip the next statements in the iteration
‘else’ statement used
with python
1. Unlike c/c++, in python you can use else statement
with python.