SlideShare a Scribd company logo
Year 7 lesson 3   variables and while loops
LESSON OBJECTIVES
Learn to use variables and ‘while’
loops to get keyboard input from
users.
LESSON OUTCOMES
 I can use variables in Python …
 I can use while loops in Python …
VARIABLES
[ slide 3 ]
A variable is a space in the computer’s memory where we can
store data such as a number or text. The value can be
changed if required.
The box represents the space reserved in the computer’s memory
To create a
variable and give
it the value 42 we
write:
>>> my_number=42variable
name
42
The variable’s
value
Outcomes:
 I can use variables in Python…
 I can use while loops in Python …
>>> my_number=0
while my_number < 10:
print (I love coding in
Python)
my_number = my_number+1
The variable is called number
The = operator gives the variable
a value 0.
This line of code says ‘while the
variable called number is
less than 10 do the
following.
All of the code that is indented
after the colon is to be
repeated by the computer – it
loops through these two lines
of code until number is no
longer less than 10.
WHILE LOOPS
Outcomes:
 I can use variables in Python…
 I can use while loops in Python …
TASK 1 – USING WHILE LOOPS
[ slide 4 ]
Open the following file: While loop.
When the file is open enter your own print output in the
print function brackets.
>>> my_number=0
>>> while my_number < 10:
print("I love coding in Python!")
my_number = my_number+1
Outcomes:
 I can use variables in Python…
 I can use while loops in Python …
When you have completed the above code attempt Task 1 on worksheet 3.
MINI PLENARY
Look at the following code:
x=0
while x<5:
print('looping')
When do you think the code will stop
looping.
Outcomes:
 I can use variables in Python…
 I can use while loops in Python …
MAIN TASK 2
Have a go at completing
Tasks 2 and 3
on the worksheet.
Outcomes:
 I can use variables in Python…
 I can use while loops in Python …
WORKSHEET ANSWERS
Outcomes:
 I can use variables in Python…
 I can use while loops in Python …
PLENARY
Can you explain what the program lines are
doing?
Outcomes:
 I can use variables in Python…
 I can use while loops in Python …
ANSWER
Outcomes:
 I can use variables in Python…
 I can use while loops in Python …

More Related Content

Similar to Year 7 lesson 3 variables and while loops (20)

PPTX
Python fundamentals
natnaelmamuye
 
PPTX
Module-1.pptx
Manohar Nelli
 
PPTX
Python knowledge ,......................
sabith777a
 
PPTX
unit1.pptx for python programming CSE department
rickyghoshiit
 
PPTX
Mastering Python lesson 3a
Ruth Marvin
 
PDF
Python made easy
Abhishek kumar
 
PDF
Python programming
Prof. Dr. K. Adisesha
 
PPTX
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
DRVaibhavmeshram1
 
PPTX
lecture 2.pptx
Anonymous9etQKwW
 
PPTX
Python Introduction Week-1 Term-3.pptx
Mohammad300758
 
PPTX
Chapter1 python introduction syntax general
ssuser77162c
 
PPTX
Python Introduction
Punithavel Ramani
 
PPTX
python introduction initial lecture unit1.pptx
ChandraPrakash715640
 
PPTX
if, while and for in Python
PranavSB
 
PDF
5 getting started with Python 1st puc syllubus
afshanaffu05
 
PDF
introduction to python programming course
FarhadMohammadRezaHa
 
PDF
problem solving and python programming UNIT 2.pdf
rajesht522501
 
PDF
Problem Solving and Python Programming UNIT 2.pdf
rajesht522501
 
Python fundamentals
natnaelmamuye
 
Module-1.pptx
Manohar Nelli
 
Python knowledge ,......................
sabith777a
 
unit1.pptx for python programming CSE department
rickyghoshiit
 
Mastering Python lesson 3a
Ruth Marvin
 
Python made easy
Abhishek kumar
 
Python programming
Prof. Dr. K. Adisesha
 
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
DRVaibhavmeshram1
 
lecture 2.pptx
Anonymous9etQKwW
 
Python Introduction Week-1 Term-3.pptx
Mohammad300758
 
Chapter1 python introduction syntax general
ssuser77162c
 
Python Introduction
Punithavel Ramani
 
python introduction initial lecture unit1.pptx
ChandraPrakash715640
 
if, while and for in Python
PranavSB
 
5 getting started with Python 1st puc syllubus
afshanaffu05
 
introduction to python programming course
FarhadMohammadRezaHa
 
problem solving and python programming UNIT 2.pdf
rajesht522501
 
Problem Solving and Python Programming UNIT 2.pdf
rajesht522501
 

More from tmoncrieff (14)

PPTX
Lesson 3-health-and-safety
tmoncrieff
 
PPTX
Lesson 2-human-computer
tmoncrieff
 
PPTX
Lesson 4 binary numbers
tmoncrieff
 
PPTX
Lesson 1 inputs and outputs
tmoncrieff
 
PPTX
Lesson 4 binary numbers
tmoncrieff
 
PPTX
Lesson 3-health-and-safety
tmoncrieff
 
PPTX
Lesson 2-human-computer
tmoncrieff
 
PPTX
Lesson 1 inputs and outputs
tmoncrieff
 
PPTX
Year 7 lesson 5 if statements
tmoncrieff
 
PPTX
Lesson 1 inputs and outputs
tmoncrieff
 
PPT
16 btec12 first_bus_u8_ps2
tmoncrieff
 
PPT
17 btec12 first_bus_u8_ps3
tmoncrieff
 
PPT
15 btec12 first_bus_u8_ps1
tmoncrieff
 
PPT
04 btec12 first_bus_u3_pp1
tmoncrieff
 
Lesson 3-health-and-safety
tmoncrieff
 
Lesson 2-human-computer
tmoncrieff
 
Lesson 4 binary numbers
tmoncrieff
 
Lesson 1 inputs and outputs
tmoncrieff
 
Lesson 4 binary numbers
tmoncrieff
 
Lesson 3-health-and-safety
tmoncrieff
 
Lesson 2-human-computer
tmoncrieff
 
Lesson 1 inputs and outputs
tmoncrieff
 
Year 7 lesson 5 if statements
tmoncrieff
 
Lesson 1 inputs and outputs
tmoncrieff
 
16 btec12 first_bus_u8_ps2
tmoncrieff
 
17 btec12 first_bus_u8_ps3
tmoncrieff
 
15 btec12 first_bus_u8_ps1
tmoncrieff
 
04 btec12 first_bus_u3_pp1
tmoncrieff
 
Ad

Recently uploaded (20)

PPSX
HEALTH ASSESSMENT (Community Health Nursing) - GNM 1st Year
Priyanshu Anand
 
PPTX
How to Manage Large Scrollbar in Odoo 18 POS
Celine George
 
PPTX
Pyhton with Mysql to perform CRUD operations.pptx
Ramakrishna Reddy Bijjam
 
PDF
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
PPTX
Mathematics 5 - Time Measurement: Time Zone
menchreo
 
PPTX
How to Convert an Opportunity into a Quotation in Odoo 18 CRM
Celine George
 
PPTX
2025 Winter SWAYAM NPTEL & A Student.pptx
Utsav Yagnik
 
PPTX
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
PPTX
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
PPTX
Views on Education of Indian Thinkers Mahatma Gandhi.pptx
ShrutiMahanta1
 
PPTX
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
PDF
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - GLOBAL SUCCESS - CẢ NĂM - NĂM 2024 (VOCABULARY, ...
Nguyen Thanh Tu Collection
 
PPTX
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
PPTX
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
PPTX
Quarter1-English3-W4-Identifying Elements of the Story
FLORRACHELSANTOS
 
PDF
CEREBRAL PALSY: NURSING MANAGEMENT .pdf
PRADEEP ABOTHU
 
PDF
Isharyanti-2025-Cross Language Communication in Indonesian Language
Neny Isharyanti
 
PPTX
How to Set Maximum Difference Odoo 18 POS
Celine George
 
PPTX
BANDHA (BANDAGES) PPT.pptx ayurveda shalya tantra
rakhan78619
 
PDF
The Different Types of Non-Experimental Research
Thelma Villaflores
 
HEALTH ASSESSMENT (Community Health Nursing) - GNM 1st Year
Priyanshu Anand
 
How to Manage Large Scrollbar in Odoo 18 POS
Celine George
 
Pyhton with Mysql to perform CRUD operations.pptx
Ramakrishna Reddy Bijjam
 
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
Mathematics 5 - Time Measurement: Time Zone
menchreo
 
How to Convert an Opportunity into a Quotation in Odoo 18 CRM
Celine George
 
2025 Winter SWAYAM NPTEL & A Student.pptx
Utsav Yagnik
 
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
Views on Education of Indian Thinkers Mahatma Gandhi.pptx
ShrutiMahanta1
 
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - GLOBAL SUCCESS - CẢ NĂM - NĂM 2024 (VOCABULARY, ...
Nguyen Thanh Tu Collection
 
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
Quarter1-English3-W4-Identifying Elements of the Story
FLORRACHELSANTOS
 
CEREBRAL PALSY: NURSING MANAGEMENT .pdf
PRADEEP ABOTHU
 
Isharyanti-2025-Cross Language Communication in Indonesian Language
Neny Isharyanti
 
How to Set Maximum Difference Odoo 18 POS
Celine George
 
BANDHA (BANDAGES) PPT.pptx ayurveda shalya tantra
rakhan78619
 
The Different Types of Non-Experimental Research
Thelma Villaflores
 
Ad

Year 7 lesson 3 variables and while loops

  • 2. LESSON OBJECTIVES Learn to use variables and ‘while’ loops to get keyboard input from users.
  • 3. LESSON OUTCOMES  I can use variables in Python …  I can use while loops in Python …
  • 4. VARIABLES [ slide 3 ] A variable is a space in the computer’s memory where we can store data such as a number or text. The value can be changed if required. The box represents the space reserved in the computer’s memory To create a variable and give it the value 42 we write: >>> my_number=42variable name 42 The variable’s value Outcomes:  I can use variables in Python…  I can use while loops in Python …
  • 5. >>> my_number=0 while my_number < 10: print (I love coding in Python) my_number = my_number+1 The variable is called number The = operator gives the variable a value 0. This line of code says ‘while the variable called number is less than 10 do the following. All of the code that is indented after the colon is to be repeated by the computer – it loops through these two lines of code until number is no longer less than 10. WHILE LOOPS Outcomes:  I can use variables in Python…  I can use while loops in Python …
  • 6. TASK 1 – USING WHILE LOOPS [ slide 4 ] Open the following file: While loop. When the file is open enter your own print output in the print function brackets. >>> my_number=0 >>> while my_number < 10: print("I love coding in Python!") my_number = my_number+1 Outcomes:  I can use variables in Python…  I can use while loops in Python … When you have completed the above code attempt Task 1 on worksheet 3.
  • 7. MINI PLENARY Look at the following code: x=0 while x<5: print('looping') When do you think the code will stop looping. Outcomes:  I can use variables in Python…  I can use while loops in Python …
  • 8. MAIN TASK 2 Have a go at completing Tasks 2 and 3 on the worksheet. Outcomes:  I can use variables in Python…  I can use while loops in Python …
  • 9. WORKSHEET ANSWERS Outcomes:  I can use variables in Python…  I can use while loops in Python …
  • 10. PLENARY Can you explain what the program lines are doing? Outcomes:  I can use variables in Python…  I can use while loops in Python …
  • 11. ANSWER Outcomes:  I can use variables in Python…  I can use while loops in Python …