0% found this document useful (0 votes)
43 views

36990-Lesson 2

This document provides an overview of a Python lesson on using if statements. It includes: 1. An example program that asks a user for their name and age, then prints their name and age on their next birthday. 2. An explanation that the lesson will teach writing simple Python programs using if statements, including more complex if statements with elif and nested if statements. 3. Homework instructions to complete example programs with if statements and a crossword puzzle.

Uploaded by

Osman Ahmed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views

36990-Lesson 2

This document provides an overview of a Python lesson on using if statements. It includes: 1. An example program that asks a user for their name and age, then prints their name and age on their next birthday. 2. An explanation that the lesson will teach writing simple Python programs using if statements, including more complex if statements with elif and nested if statements. 3. Homework instructions to complete example programs with if statements and a crossword puzzle.

Uploaded by

Osman Ahmed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Python

Lesson 2

1
Starter
Start Python and create a program which will ask
for the user’s name and current age and then will
say Hello and will display their age on their next
birthday.
Possible Solution:

2
Objective of the lesson
Write simple programs using Python.

• All of you will:


– Use If statements to make a decision.
• Most of you will:
– Use more complex If statements including “elif”.
• Some of you will:
– Create If statements within other If statements.

3
Homework
• Everybody should complete Tasks
1 and 2 to find the errors in the
program and complete the
crossword.
• Some of you may also want to get
the extra marks by completing the
extension activity.
• This homework is due in next
lesson.
• Make sure you have written your
homework clearly in your planner.

4
## is used to create
comments which are
If Statements ignored by Python but make
the code easier to
What will this code do? understand.

if is used to decide if an
action is going to be
followed. It ends with a :
symbol.

Indents are very


else is used to describe important as this
what will happen if the tells Python where
first condition has not the different sections
been met. start and end.
5
More If Statements
if condition: if is used to decide if an action is
Statement going to be followed.
elif condition:
Statement elif stands for “else if” where you
else: can test another condition.
Statement
else is used to tell Python what to
do if it hasn’t met any other
conditions.

6
Try these out…
Follow the instructions
on the sheet to recap If
statements.

Remember to save them


all with a suitable name
followed by .py

You might also like