Control
Statements
The if Statements
• Python program control flow is regulated by various types of
conditional statements, loops, and function calls.
• We would like the program to have a decision-making
ability, so that it performs different steps depending on
different conditions.
• Python provides if..elif..else control statements as a part of
decision marking.
If
Statement
Syntax of If Statement
if Statements
Conditions & If statements
The and keyword is a logical operator
The or keyword is a logical operator
The not keyword is a logical operator
Find the absolute value of a number
If Else
Statement
Syntax of If Else
Checking if a number is even or odd
Checking if a string contains a certain
character
if…elif…else
Statement
Syntax
While purchasing certain items, a discount of 10% is
offered if the quantity purchased is more than 10.
Employee Bonus Program in Python
Student Percentage Program in Python
Youngest Age of Three Program in Python
Example:
Leap Year or Not Program in Python
Nested if Statements
Syntax:
if (condition1):
# Executes when condition1 is true
if (condition2):
# Executes when condition2 is true
# if Block 2 is end here
# if Block 1 is end here
Python pass Statement
• The Python pass statement is a null statement.
• But the difference between pass and comment is that
comment is ignored by the interpreter where as pass
is not ignored.
• So using a pass statement user avoids this error.
Syntax of the pass statement
pass
To Check Number is divided by 3 and 5
Validate User_id in the list of User_ids
Print a square or cube of the given number
Character is Uppercase or Not.
Number is an Integer or Not.
To check whether an alphabet is a vowel
Read month and returns season for that month
Round up the number to 2 decimal places
Mathematical Operations
Python Program to Calculate Electricity
Bill
Thank You