You are on page 1of 15

Selection Control

SY 2020-2021 3rd Term


CS001L Computer Fundamentals and Programming 1
Laboratory
Objectives
After completing this lesson, students will be able
to:

➢Effectively use if statements for selection control.


➢Explain the use of indentation.
➢Effectively implement multi-way selection in
Python.
Selection Control
A selection control statement is a control
statement providing selective execution of
instructions.
A selection control structure is a given set of
instructions and the selection control
statement(s)
controlling their execution.
If Statement
An if statement is a selection control
statement based on the value of a
given Boolean expression.
Statements that contain other
statements are referred to as a
compound statement.
If Statement
If Statement
Indentation in Python
Indentation in Python
Try
this!

From IDLE, create and run


a Python program
containing the code on
the left and observe the
results.
Multi-Way Selection

If statements can be nested in Python,


resulting in multi-way selection.
Multi-Way Selection:
Nested If Statements
Try
this!

From IDLE, create and run


a Python program
containing the code on
the left and observe the
results.
The elif Header in Python
If statements may contain any number of elif headers,
providing for multi-way selection.
Try
this!

From IDLE, create and run


a Python program
containing the code on
the left and observe the
results.
End
Thanks!

You might also like