Flow of control: introduction, use of indentation, sequential flow, conditional and iterative flow control
Types of statements in Python :
Statements are the instructions given to the computer to perform any kind of action. Python statements can belong to one of the following three types.
(1) Empty Statement
A statement that does nothing.In Python an empty statement is pass statement. It takes the following form:
pass
Whenever Python encounters a pass statement, Python does nothing and moves to next statement in the flow of control.
Simple Statement
Any executable statement is a simple statement in Python. For example:
Name=input(“enter your name”)
Compound Statement
A compound statement represents a group of statements executed as a unit.
The compound statement in Python are written in a specific pattern .
It has
: -> A header line which begins with a keyword and ends with a colon.
-> A body consisting of one or more Python statements, each indented inside the header line
Python uses indentation to highlight the blocks of code. Whitespace is used for indentation in Python. All statements with the same distance to the right belong to the same block of code.
Statement Flow Control :
In a program statements may be executed sequentially, selectively or iteratively.
Every programming language provides constructs to support sequence, selection or iteration.
Decision Making( Conditional ) statements :
1. if statements
2. if-else statements
3. if-elif-else statements
4. nested if statements
Iterative(looping) Statements
for loop
while loop
The iteration constructs mean repetition of a set of statements depending upon a condition-test. Till the time a condition is true, a set of statements are
repeated again and again. As soon as the condition becomes False, the repetition stops. The iteration construct is also called looping construct.