PERFORMING CONDITIONAL
PROGRAMMING USING
PYTHON
3rd Quarter
A. Algorithms
•An algorithm is a
step-by-step set of
instructions to solve a
problem.
•Algorithms follow a
•Algorithms are
independent of
programming languages.
•One algorithm can be
implemented using
different programming
languages.
•
B. Flowcharts
•A flowchart is a visual
representation of an algorithm.
•Flowchart symbols:
• Oval – Start / End
• Rectangle – Process
• Diamond – Decision
• Arrow / Flowline –
Direction of flow
•Flowlines show the
sequence of steps.
•Incorrect decision
boxes can lead to
wrong program
output.
C. Pseudocode
•Pseudocode is a
structured, English-like
way of writing
algorithms.
•It focuses on logic,
•Common keywords:
•START / END
•INPUT / PRINT
•IF / ELSE / ENDIF
•Helps programmers
test logic before
D. IF Statements (Decision
Structures)
•IF statements are used for
decision-making.
•A condition must be TRUE or
FALSE.
•If the condition is FALSE, the IF
block is skipped.
•END IF marks where the
START
PRINT "Enter your age:"
INPUT age
IF age >= 18 THEN #checks the
condition
PRINT "You are eligible to vote."
ENDIF
END
•If the condition is TRUE, the message prints
•If the condition is FALSE, the block is skipped
E. IF–ELSE Statements
•IF → executes when
condition is TRUE
•ELSE → executes when
condition is FALSE
•Ensures programs give the
correct output based on
conditions.
START
PRINT "Enter your age: "
INPUT age
IF age >= 18 THEN
PRINT "You are eligible to
vote."
ELSE
PRINT "YouNote:are not
•IF age >= 18 THEN → Checks the condi
eligible to vote."
•If TRUE, executes the first block
ENDIF •ELSE → Executes if the condition is FALS
•ENDIF → Marks the end of the condition
F. Multiple Conditions (IF–
ELIF–ELSE)
•Used when there are more
than two choices.
•Conditions are checked in
this order:
• IF → ELIF → ELSE
•Only one condition is
#Grade Classification Program
grade = int(input("Enter your
grade: "))
if grade >= 90:
print("Outstanding")
elif grade >= 75:
print("Passed")
else:
print("Failed")
How This Code Works (Step-by-
Step)
[Link] user enters a grade
[Link] program checks conditions in
order:
•IF grade >= 90 → executed if
TRUE
•ELIF grade >= 75
•ELSE → runs if all conditions are
FALSE
[Link] one message is printed