Python Conditional Statements and Logic
Year 9 Computing Programming Fundamentals with Python Lesson 6 of 10
What Are Conditional Statements?
Allow programs to make decisions Control the flow of execution Execute different code based on conditions Essential for interactive programs
The IF Statement
Basic conditional structure Executes code only if condition is True Syntax: if condition: Must be followed by indented code block

Code Along: Simple IF Statement
temperature = 15 if temperature < 20: print('It's cool outside') What happens if temperature = 25?
ELIF and ELSE Statements
ELIF: checks additional conditions ELSE: runs when no conditions are met Creates multiple decision paths Only one block executes per conditional chain
Quick Check: What's the Output?
age = 16 if age < 13: print('Child') elif age < 18: print('Teenager') else: print('Adult')

Your Turn: Weather Clothing Advisor
Create a program that asks for weather and temperature Use if-elif-else to suggest clothing Include at least one logical operator (and/or) Test with different inputs
1 more slide available after you open the deck.
Download all 8 slides