0% found this document useful (0 votes)
30 views24 pages

Session 5 Decision Making in Python

The document provides an overview of decision-making constructs in Python programming, including if statements, if-else, elif, and nested conditions. It also discusses the importance of libraries in Python, highlighting popular libraries like Matplotlib, Pandas, and Scrapy, and mentions the use of pip for managing packages. Additionally, it emphasizes the necessity of reading documentation for understanding module functionalities.

Uploaded by

nsmatharoo63
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views24 pages

Session 5 Decision Making in Python

The document provides an overview of decision-making constructs in Python programming, including if statements, if-else, elif, and nested conditions. It also discusses the importance of libraries in Python, highlighting popular libraries like Matplotlib, Pandas, and Scrapy, and mentions the use of pip for managing packages. Additionally, it emphasizes the necessity of reading documentation for understanding module functionalities.

Uploaded by

nsmatharoo63
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 24

Search . . .

Decision Making
In Python
Session-5
simrantechmentor
simrantechmentor

Decision Making
Conditional Construct
The ability to make decisions quickly
and accurately is essential to being a
successful programmer.

Decision making is a critical part of


computer programming because you
will often be given multiple options and
will have to choose one based on
specific conditions.
Examples Search . . .

Giving discount based on condition

Amount Withdraw based on balance in account

Logging to online account based on the credentials.

Assigning grade to student based on Marks

simrantechmentor
Implementing Decision Search . . .

Making
if statement

If… else

elif

nested if

nested if-else statement

simrantechmentor
If statement Search . . .

if allows us to execution conditional code.

Code inside if only execute if the expression with if returns True.

simrantechmentor
Search . . .

Demonstration if statement
Program if_statement.py (Folder In-class Demo) Lab 5
If..else statement Search . . .

if allows us to execution conditional code.

Code inside “if” section execute if the expression with if returns True, if it return False “else”
section will execute .

Important Note : You


cannot write expression
with else.

simrantechmentor
Search . . .

Demonstration if.. else statement


Program if_else.py (Folder In-class Demo) Lab 5
elif statement Search . . .

simrantechmentor
Implementing elif statement Search . . .

The elif statement adds another "decision" branch to if-else.

say you want to evaluate multiple expressions, then you can use elif

when the if statement is false, the next elif expression is checked.

When any one expression is true, the control goes outside the if-else block.

At most, one block would be executed. In case else is not specified, and all
the statements are false, none of the blocks would be executed.

simrantechmentor
Demonstration elif statement Search . . .

Program elif_statement.py (Folder In-class Demo) Lab 5


Nested if Search . . .

simrantechmentor
Demonstration nested if statement Search . . .

Program nestedif_statement.py (Folder In-class Demo) Lab 5


Nested if-else Search . . .

simrantechmentor
Demonstration nested if else statement Search . . .

Program nestedifelse_statement.py (Folder In-class Demo) Lab 5


WORKING WITH PYTHON LIBRARIES
Libraries Search . . .

A library is a term referring to a reusable chunk of code. Python library


contains a collection of related modules and packages.

A module is a file that contains collection of functionality.

a package is a collection of modules

a library is a collection of packages

simrantechmentor
Few Famous Libraries Search . . .

Matplotlib PyGame
is a standard library for
generating data visualizations This library provides an easy
in Python. It supports building interface to (SDL) platform-
basic two-dimensional graphs independent graphics, audio,
as well as more complex and input libraries. It is used
animated and interactive for developing video games
visualizations.

Pandas Scrapy
an important library for data It is an open-source library
scientists. It is an open-source that is used for extracting
machine learning library that data from websites. It
provides flexible high-level provides very fast web
data structures and a variety crawling and high-level screen
of analysis tools. It eases data scraping. It can also be used
analysis, data manipulation, for data mining and
and cleaning of data.
simrantechmentor
automated testing of data.
Libraries Search . . .

Python has more than 137000 libraries.

These libraries used to create applications and models in a variety of


fields, for instance, machine learning, data science, data visualization,
image and data manipulation, and many more
Few libraries are installed with Python SDK. Few we have to install as per our
requirement

Pip is a package manager use to install or uninstall package in python.

“pip install matplotlib”

simrantechmentor
DEMONSTRATION MATH MODULE
Program math_module.py (Folder In-class Demo) Lab 5

Always read
documentation to
check the functionality
of modules
DEMONSTRATION RANDOM MODULE
Program random_module.py (Folder In-class Demo) Lab 5

Always read
documentation to
check the functionality
of modules
DEMONSTRATION DATETIME MODULE
Program date_time.py (Folder In-class Demo) Lab 5

Always read
documentation to
check the functionality
of modules
DEMONSTRATION DATETIME MODULE
Program alias_module.py (Folder In-class Demo) Lab 5

Always read
documentation to
check the functionality
of modules
Search . . .

THANK YOU
Kindly perform all in class exercise before coming to lab

END SLIDE

simrantechmentor
Contact No : 9878138788
Email : [email protected]

You might also like