Lesson-1.-UNDERSTANDING-CONDITIONAL-CONTROL-STRUCTURE
Lesson-1.-UNDERSTANDING-CONDITIONAL-CONTROL-STRUCTURE
Lesson
1
Understanding
Conditional Control
Structure
UNIT 3: Performing Conditional
Programming Using Python
Conditional Control Structure
is used in programs to perform
statement based on the conditions.
True
Condition Statements
False
Statement
Are provided after the condition.
Decision Box
Has the condition answered by true
or false.
Flowlines
Direct the flow from top to bottom
and from left to right in a flowchart.
Analyzing the problem is the
first step when given a problem.
It involves identifying the
objective, the requirement for
the program to work and the user
inputs.
Algorithm
Is a procedure created to instruct
the computer what steps to perform to
achieve the operation objectives.
We first analyze the problem by
identifying the objective the requirement
and the user inputs.
Example:
PIN (Personal Identification
Number)
is an alphanumeric password
used to authenticate a user’s
access in a system.
Objective: To display a message once the
entered
PIN is correct. The program should
have a
stored PIN. The PIN is “123” and
stored in
Pseudocode:
1. Assign the PIN to a variable.
2. Display the instruction to the user to
enter his or
3. her PIN.the entered PIN.
Accept
4. Evaluate if the entered PIN is the same as
the
5. stored PIN.a message when the PIN is
Display
correct.
Here is a flowchart to display a message once entered
PIN is correct: Start
Code = “123”
Output
“Please enter
the PIN:”
Enter PIN
Output “The
If PIN = PIN is
code?
correct.”
End
Example:
Score Remark
Passing Score =
7.5
Output “Please
enter your
score:”
Enter score
If score >=
Yes Output “You
passing passed the
score? quiz!”
No
End
Activity 1: Set the Conditions
Analyze the programs carefully. Write the condition of each program
in the corresponding column.
Program Condition
1. Color Guessing Game
Create a program that asks the user to guess the color.
2. Odd Number Identifier
Create a program that identifies if the entered number is
an odd number. Use the mod operator.
3. Divisibility Program
Create a program that identifies if the entered number is
divisible by 7. Use the mod operator.
Activity 1: Set the Conditions
Analyze the programs carefully. Write the condition of each program
in the corresponding column.
Program Condition
1. Color Guessing Game Guess = color?
Create a program that asks the user to guess the color.
2. Odd Number Identifier n%2 = 0
Create a program that identifies if the entered number is
an odd number. Use the mod operator.
3. Divisibility Program Is n mod 7 = 0?
Create a program that identifies if the entered number is
divisible by 7. Use the mod operator.
Activity 2: Draw the Flowchart
Create a flowchart and draw the symbol.
1. Color guessing game
Flowchart Start
Number = 7
“Guess the
number”
Guess input
False
Guess =
number ?
True
“Incorrect”
“Correct”
Game over