GCSE variables

GCSE variables
1 / 33
next
Slide 1: Slide
ComputingUpper Secondary (Key Stage 4)GCSE

This lesson contains 33 slides, with interactive quizzes, text slides and 1 video.

Items in this lesson

GCSE variables

Slide 1 - Slide

How do you feel about your programming?
😒🙁😐🙂😃

Slide 2 - Poll

In this lesson you will:

- Understand the difference between a variable and a constant.
- Understand the role of memory locations in variables.
- Comprehend the concepts of declaring and initialising variables.
- Recognise the importance of meaningful variable names.
Useful information - w3 schools Python

Slide 3 - Slide

Learners expectations:

- All learners take part in the lesson.
- Until I set you on task learners are to be silent and solo, If learners have questions raise your hand rather than shouting out.
- I understand some learners may already know parts of this lesson, I will assess this quickly and then if you feel confident and can answer the first questions on notebook then I will set you on task while delivering the content to the other learners.

Slide 4 - Slide

With your paired partner, I will set a two minute timer discuss anything you both remember about IDE's compilers, interpreters and translators.

Slide 5 - Slide

Write one feature of an IDE

Slide 6 - Open question

Give one example of an IDE

Slide 7 - Open question

What do you know about variables? if nothing what do you think a variable is?

Slide 8 - Open question

Look at the first questions in your notebook can you answer them? If you can raise your hands. 

Slide 9 - Slide

Driver:

The Driver is the person who types the code. You are responsible for writing the program, making changes, and running the code.
Your focus is on following the plan and coding carefully.
While typing, you should make sure the code is correct (check for errors) and logical.
If you’re unsure about something, don’t hesitate to ask your Navigator for advice, but try to stay focused on the task of coding.
Key Responsibilities for the Driver:

Write the code.
Follow the plan based on the discussion with your partner.
Test the code and make sure it runs correctly.
Stay focused on implementing the solution as discussed.

Slide 10 - Slide

Navigator:

The Navigator is the person who guides the Driver. You are not typing the code, but you’re thinking critically about what to do next and helping the Driver stay on track.
Your role is to think through the problem, look for errors, and provide feedback or suggestions on how to improve the code.
You need to help the Driver debug the code, make sure it’s logically correct, and ask questions to ensure understanding.
Key Responsibilities for the Navigator:

Think about the overall logic and look for mistakes in the code.
Provide guidance and suggest changes to improve the code.
Help debug any errors or unexpected behavior.
Encourage your partner by explaining what might need to be changed, without taking over the keyboard.

Slide 11 - Slide

Instructions:

Before you begin, decide who will be the Driver and who will be the Navigator. You will switch roles halfway through.
Driver: Type the code as the Navigator suggests and guides you. Make sure to follow the plan and write each line carefully.
Navigator: Help the Driver by thinking ahead. Ask questions, like:
"What type of variable should we use to store the age?"
"Have we handled edge cases? What if the user enters an invalid age?"
Once you run the code, check the output. If something is wrong, work together to investigate and debug it. The Navigator should lead the investigation while the Driver makes the necessary changes.
After 5 minutes, switch roles so you both have a chance to drive and navigate. The new Driver should continue where the previous Driver left off.

Slide 12 - Slide

We look at variables as objects we assign values to.


Slide 13 - Slide

Interger
String
Boolean
Float
81
'Hello'
False
3.14

Slide 14 - Drag question

Can you think of any real-life examples where we use variables?

Slide 15 - Open question

Slide 16 - Video

Detailed variable explanation

A variable is a storage location in a program where data can be stored, retrieved, and manipulated. Each variable has a name, a data type (e.g., integer, string), and a value. The value of a variable can change throughout the program.

Slide 17 - Slide

Python is a typed language and interpreted at run time so variables can be changed.





Slide 18 - Slide

This cannot be done in other languages where variables are assigned a type when created and cannot be changed.

Slide 19 - Slide

There are also different ways variables can be used including global, private and constants. Python doesn't have constant variables but other languages do.

Slide 20 - Slide

In memory locations can be named by the computer architecture. 




When we assign a variable its name is changed to that of the variable so when we say the name of the variable it pulls the data from that location.

Slide 21 - Slide

When we create a variable we assign a name and also in some languages a type. This is how we declare variables. 

Variables are initialised when they are assigned a value. In python this can be when they are declared, but in other languages they must be declared first.


Slide 22 - Slide

When we name variables there are different methods we can use:

camelCase
Pascal Case
snake_case

A variable name must start with a letter or the underscore character and a variable name cannot start with a number.


Slide 23 - Slide

b = d*e what do you think this is?

Slide 24 - Open question

area = base * height what do you think this is?

Slide 25 - Open question

Variable naming conventions are important, the variable names give context to what the code is doing and make it much easier to understand.

Slide 26 - Slide

Work your way through your class notebooks, this is to be done silent and solo. This allows students to think and absorb the information you have been given and work effectively. 

Should you require 1-1 support raise your hand and I will come and help you.

Slide 27 - Slide

What is a variable?

Slide 28 - Open question

One thing I learned this lesson was?

Slide 29 - Open question

Given the choice the approach that I enjoy and helped me with my programming the most was?
A
PRIMM SOLO
B
PRIMM PAIRED

Slide 30 - Quiz

My confidence with variables is?
😒🙁😐🙂😃

Slide 31 - Poll

Extension
Silent and solo complete this:
Scenario: Create a program that asks the user for their age and then tells them how many years until they turn 100.

With your pair:
Create a program that asks for the user’s birth year instead of their age and then calculates how many years until they turn 100.

Slide 32 - Slide

Slide 33 - Link