Python Control Statements

The two most commonly used statements in any programming language are as follows :

Sequential statements: These are the statements which are executed one by one.

Control statements: These are the statements that are executed randomly and repeatedly.

Program 1: A Python program to calculate the area of a circle.

CopiedCopy Code

import math
r = float(input('Enter radius:'))
area = math.pi * r**2
print('Area of circle=', area) 
print('Area of circle= %.2f' %(area))

Here the instructions are executed one by one by the Python interpreter This is called sequential execution. This type of execution is suitable only for developing simple programs. It is not suitable for developing critical programs where complex logic is needed.

Control Statements

  1. if statement
  2. if ... else statement
  3. if ... elif ... else statement
  4. while loop
  5. for loop
  6. else suite
  7. break statement
  8. continue statement
  9. pass statement
  10. assert statement
  11. return statement

Please note that the switch statement found in many languages like C and Java is not available in Python.