0% found this document useful (0 votes)
5 views

Python Programming

Uploaded by

Abhijit Bhatye
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Python Programming

Uploaded by

Abhijit Bhatye
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Python Programming

Control Structures
Control Structures
• Structures used to manage flow of program.
• Types
• Selection / Branching / Decision Making Statements
• Loops / Iteration / Repetition statements
if statement
• If is a selection statement.
• Syntax
if <<condition>>:
<<body of if>>
• It executes <<body of if>> if the <<condition>> is true otherwise it will
be ignored.
• Example
if num%2==0:
print( str( num )+” is even”)
If – else
• Syntax
if <<condition>>:
<<body of if>>
else:
<<body of else>>
• Executes <<body of if>> if <<condition is true>> otherwise executes <<body of else>>
• Example
if num%2==0:
print(str( num )+” is even”);
else :
print(str( num )+” is odd”);
if – elif - else
• Syntax
if <<condition 1>>:
<<body for cond 1>>
elif <<condition 2>>
<<body for cond 2>>
.
.
.
.
else:
<<body of else>>
If-elif-else
• <<body for cond1>> will be executed if <<cond1> is true otherwise
second condition will be checked this process is continued until one
condition is found to be true and then body of that condition will be
executed. If no condition is satishfied body of else will be executed

You might also like