Day5_PythonDecesion_Making
Day5_PythonDecesion_Making
[Unit INSTITUTE
1: Introduction OF ELECTRONICS
to Web Design] AND
Course: INFORMATION
NIELIT TECHNOLOGY
‘O’ Level (IT)
Sumit Complex, A-1/9, Vibhuti Khand,
Module: Gomti
M2-R5: Nagar,
Web Lucknow,
Designing & Publishing
1
Basic Python
Day5
[UnitCourse
1: Introduction to Web Design]
: Basic Python
Course: NIELIT ‘O’ Level (IT)
Day5 : Python Decision Making Module: M2-R5: Web Designing & Publishing
2 Index
Decision Making in Python
Indentation in Python
The if statement
The if…..elif….else statement
[UnitCourse
1: Introduction to Web Design]
: Basic Python Course: NIELIT ‘O’ Level (IT)
Day5 : Python Decision Making Module: M2-R5: Web Designing & Publishing
3 Decision Making in Python
In python, decision making is performed by the following statements.
[UnitCourse
1: Introduction to Web Design]
: Basic Python Course: NIELIT ‘O’ Level (IT)
Day5 : Python Decision Making Module: M2-R5: Web Designing & Publishing
4
IF FLOW CHART.
[UnitCourse
1: Introduction to Web Design]
: Basic Python Course: NIELIT ‘O’ Level (IT)
Day5 : Python Decision Making Module: M2-R5: Web Designing & Publishing
5 Indentation in Python
In python, decision making is performed by the following statements.
For the ease of programming and to achieve simplicity, python doesn't allow the use of
parentheses for the block level code.
Indentation is used to declare a block. If two statements are at the same indentation level, then
they are the part of the same block.
Four spaces are given to indent the statements which are a typical amount of indentation in
python.
[UnitCourse
1: Introduction to Web Design]
: Basic Python Course: NIELIT ‘O’ Level (IT)
Day5 : Python Decision Making Module: M2-R5: Web Designing & Publishing
6 The if statement
The if statement is used to test a particular condition and if the condition is true, it executes a
block of code known as if-block.
If it amounts to False, then the block is skipped and control transfers to the statements after
the block.
The syntax of the if-statement is given below.
if condition:
statement
[UnitCourse
1: Introduction to Web Design]
: Basic Python Course: NIELIT ‘O’ Level (IT)
Day5 : Python Decision Making Module: M2-R5: Web Designing & Publishing
7
The if statement is used to test a particular condition and if the condition is true, it executes a block
of code known as if-block.
If it amounts to False, then the block is skipped and control transfers to the statements after the block.
The syntax of the if-statement is given below.
if condition:
statement
Example
num = int (input("enter the number:"))
if(num%2 == 0):
print("Number is even")
[UnitCourse
1: Introduction to Web Design]
: Basic Python Course: NIELIT ‘O’ Level (IT)
Day5 : Python Decision Making Module: M2-R5: Web Designing & Publishing
8
Example
num = int (input("enter the number:"))
if(num%2 == 0):
print("Number is even")
Note:
Thank You