1
Slide 1

Python Conditional Statements and Logic

Year 9 Computing Programming Fundamentals with Python Lesson 6 of 10

2
Slide 2

What Are Conditional Statements?

Allow programs to make decisions Control the flow of execution Execute different code based on conditions Essential for interactive programs

3
Slide 3

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
Slide 4

Code Along: Simple IF Statement

temperature = 15 if temperature < 20: print('It's cool outside') What happens if temperature = 25?

5
Slide 5

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

7
Slide 7

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
Slide 8

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