SlideShare a Scribd company logo
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

Python fundamentals
Python fundamentalsPython fundamentals
Python fundamentals
natnaelmamuye
 
Module-1.pptx
Module-1.pptxModule-1.pptx
Module-1.pptx
Manohar Nelli
 
Python basics
Python basicsPython basics
Mastering Python lesson 3a
Mastering Python lesson 3aMastering Python lesson 3a
Mastering Python lesson 3a
Ruth Marvin
 
Python made easy
Python made easy Python made easy
Python made easy
Abhishek kumar
 
Python programming
Python programmingPython programming
Python programming
Prof. Dr. K. Adisesha
 
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
DRVaibhavmeshram1
 
lecture 2.pptx
lecture 2.pptxlecture 2.pptx
lecture 2.pptx
Anonymous9etQKwW
 
Python Introduction Week-1 Term-3.pptx
Python Introduction Week-1 Term-3.pptxPython Introduction Week-1 Term-3.pptx
Python Introduction Week-1 Term-3.pptx
Mohammad300758
 
python into.pptx
python into.pptxpython into.pptx
python into.pptx
Punithavel Ramani
 
python introduction initial lecture unit1.pptx
python introduction initial lecture unit1.pptxpython introduction initial lecture unit1.pptx
python introduction initial lecture unit1.pptx
ChandraPrakash715640
 
if, while and for in Python
if, while and for in Pythonif, while and for in Python
if, while and for in Python
PranavSB
 
Python by Rj
Python by RjPython by Rj
Mastering Python : 100+ Solved and Commented Exercises to Accelerate Your Lea...
Mastering Python : 100+ Solved and Commented Exercises to Accelerate Your Lea...Mastering Python : 100+ Solved and Commented Exercises to Accelerate Your Lea...
Mastering Python : 100+ Solved and Commented Exercises to Accelerate Your Lea...
Lucky Gods
 
Intro to Python Programming Language
Intro to Python Programming LanguageIntro to Python Programming Language
Intro to Python Programming Language
Dipankar Achinta
 
Python_Introduction&DataType.pptx
Python_Introduction&DataType.pptxPython_Introduction&DataType.pptx
Python_Introduction&DataType.pptx
HaythamBarakeh1
 
This is all about control flow in python intruducing the Break and Continue.pptx
This is all about control flow in python intruducing the Break and Continue.pptxThis is all about control flow in python intruducing the Break and Continue.pptx
This is all about control flow in python intruducing the Break and Continue.pptx
elezearrepil1
 
Python for Beginners(v1)
Python for Beginners(v1)Python for Beginners(v1)
Python for Beginners(v1)
Panimalar Engineering College
 
python-160403194316.pdf
python-160403194316.pdfpython-160403194316.pdf
python-160403194316.pdf
gmadhu8
 
Notes2
Notes2Notes2
Notes2
hccit
 

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

Python fundamentals
Python fundamentalsPython fundamentals
Python fundamentals
 
Module-1.pptx
Module-1.pptxModule-1.pptx
Module-1.pptx
 
Python basics
Python basicsPython basics
Python basics
 
Mastering Python lesson 3a
Mastering Python lesson 3aMastering Python lesson 3a
Mastering Python lesson 3a
 
Python made easy
Python made easy Python made easy
Python made easy
 
Python programming
Python programmingPython programming
Python programming
 
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
 
lecture 2.pptx
lecture 2.pptxlecture 2.pptx
lecture 2.pptx
 
Python Introduction Week-1 Term-3.pptx
Python Introduction Week-1 Term-3.pptxPython Introduction Week-1 Term-3.pptx
Python Introduction Week-1 Term-3.pptx
 
python into.pptx
python into.pptxpython into.pptx
python into.pptx
 
python introduction initial lecture unit1.pptx
python introduction initial lecture unit1.pptxpython introduction initial lecture unit1.pptx
python introduction initial lecture unit1.pptx
 
if, while and for in Python
if, while and for in Pythonif, while and for in Python
if, while and for in Python
 
Python by Rj
Python by RjPython by Rj
Python by Rj
 
Mastering Python : 100+ Solved and Commented Exercises to Accelerate Your Lea...
Mastering Python : 100+ Solved and Commented Exercises to Accelerate Your Lea...Mastering Python : 100+ Solved and Commented Exercises to Accelerate Your Lea...
Mastering Python : 100+ Solved and Commented Exercises to Accelerate Your Lea...
 
Intro to Python Programming Language
Intro to Python Programming LanguageIntro to Python Programming Language
Intro to Python Programming Language
 
Python_Introduction&DataType.pptx
Python_Introduction&DataType.pptxPython_Introduction&DataType.pptx
Python_Introduction&DataType.pptx
 
This is all about control flow in python intruducing the Break and Continue.pptx
This is all about control flow in python intruducing the Break and Continue.pptxThis is all about control flow in python intruducing the Break and Continue.pptx
This is all about control flow in python intruducing the Break and Continue.pptx
 
Python for Beginners(v1)
Python for Beginners(v1)Python for Beginners(v1)
Python for Beginners(v1)
 
python-160403194316.pdf
python-160403194316.pdfpython-160403194316.pdf
python-160403194316.pdf
 
Notes2
Notes2Notes2
Notes2
 

More from tmoncrieff

Lesson 3-health-and-safety
Lesson 3-health-and-safetyLesson 3-health-and-safety
Lesson 3-health-and-safety
tmoncrieff
 
Lesson 2-human-computer
Lesson 2-human-computerLesson 2-human-computer
Lesson 2-human-computer
tmoncrieff
 
Lesson 4 binary numbers
Lesson 4   binary numbersLesson 4   binary numbers
Lesson 4 binary numbers
tmoncrieff
 
Lesson 1 inputs and outputs
Lesson 1   inputs and outputsLesson 1   inputs and outputs
Lesson 1 inputs and outputs
tmoncrieff
 
Lesson 4 binary numbers
Lesson 4   binary numbersLesson 4   binary numbers
Lesson 4 binary numbers
tmoncrieff
 
Lesson 3-health-and-safety
Lesson 3-health-and-safetyLesson 3-health-and-safety
Lesson 3-health-and-safety
tmoncrieff
 
Lesson 2-human-computer
Lesson 2-human-computerLesson 2-human-computer
Lesson 2-human-computer
tmoncrieff
 
Lesson 1 inputs and outputs
Lesson 1   inputs and outputsLesson 1   inputs and outputs
Lesson 1 inputs and outputs
tmoncrieff
 
Year 7 lesson 5 if statements
Year 7 lesson 5   if statementsYear 7 lesson 5   if statements
Year 7 lesson 5 if statements
tmoncrieff
 
Lesson 1 inputs and outputs
Lesson 1   inputs and outputsLesson 1   inputs and outputs
Lesson 1 inputs and outputs
tmoncrieff
 
16 btec12 first_bus_u8_ps2
16 btec12 first_bus_u8_ps216 btec12 first_bus_u8_ps2
16 btec12 first_bus_u8_ps2
tmoncrieff
 
17 btec12 first_bus_u8_ps3
17 btec12 first_bus_u8_ps317 btec12 first_bus_u8_ps3
17 btec12 first_bus_u8_ps3
tmoncrieff
 
15 btec12 first_bus_u8_ps1
15 btec12 first_bus_u8_ps115 btec12 first_bus_u8_ps1
15 btec12 first_bus_u8_ps1
tmoncrieff
 
04 btec12 first_bus_u3_pp1
04 btec12 first_bus_u3_pp104 btec12 first_bus_u3_pp1
04 btec12 first_bus_u3_pp1
tmoncrieff
 

More from tmoncrieff (14)

Lesson 3-health-and-safety
Lesson 3-health-and-safetyLesson 3-health-and-safety
Lesson 3-health-and-safety
 
Lesson 2-human-computer
Lesson 2-human-computerLesson 2-human-computer
Lesson 2-human-computer
 
Lesson 4 binary numbers
Lesson 4   binary numbersLesson 4   binary numbers
Lesson 4 binary numbers
 
Lesson 1 inputs and outputs
Lesson 1   inputs and outputsLesson 1   inputs and outputs
Lesson 1 inputs and outputs
 
Lesson 4 binary numbers
Lesson 4   binary numbersLesson 4   binary numbers
Lesson 4 binary numbers
 
Lesson 3-health-and-safety
Lesson 3-health-and-safetyLesson 3-health-and-safety
Lesson 3-health-and-safety
 
Lesson 2-human-computer
Lesson 2-human-computerLesson 2-human-computer
Lesson 2-human-computer
 
Lesson 1 inputs and outputs
Lesson 1   inputs and outputsLesson 1   inputs and outputs
Lesson 1 inputs and outputs
 
Year 7 lesson 5 if statements
Year 7 lesson 5   if statementsYear 7 lesson 5   if statements
Year 7 lesson 5 if statements
 
Lesson 1 inputs and outputs
Lesson 1   inputs and outputsLesson 1   inputs and outputs
Lesson 1 inputs and outputs
 
16 btec12 first_bus_u8_ps2
16 btec12 first_bus_u8_ps216 btec12 first_bus_u8_ps2
16 btec12 first_bus_u8_ps2
 
17 btec12 first_bus_u8_ps3
17 btec12 first_bus_u8_ps317 btec12 first_bus_u8_ps3
17 btec12 first_bus_u8_ps3
 
15 btec12 first_bus_u8_ps1
15 btec12 first_bus_u8_ps115 btec12 first_bus_u8_ps1
15 btec12 first_bus_u8_ps1
 
04 btec12 first_bus_u3_pp1
04 btec12 first_bus_u3_pp104 btec12 first_bus_u3_pp1
04 btec12 first_bus_u3_pp1
 

Recently uploaded

PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
AyyanKhan40
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
Celine George
 
Wound healing PPT
Wound healing PPTWound healing PPT
Wound healing PPT
Jyoti Chand
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
heathfieldcps1
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Excellence Foundation for South Sudan
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
amberjdewit93
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
adhitya5119
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
eBook.com.bd (প্রয়োজনীয় বাংলা বই)
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
GeorgeMilliken2
 
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptxBeyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
EduSkills OECD
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
adhitya5119
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
PECB
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Fajar Baskoro
 
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
Nguyen Thanh Tu Collection
 
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptxPrésentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
siemaillard
 
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
imrankhan141184
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
Academy of Science of South Africa
 
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptxChapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Denish Jangid
 
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
Nguyen Thanh Tu Collection
 

Recently uploaded (20)

PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
 
Wound healing PPT
Wound healing PPTWound healing PPT
Wound healing PPT
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
 
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
 
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptxBeyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
 
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
 
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptxPrésentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
 
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
 
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptxChapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptx
 
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
 

Year 7 lesson 3 variables and while loops

  • 1.
  • 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 …