
Variables
Presentation
•
Computers
•
9th - 10th Grade
•
Medium
M Dwedari
Used 19+ times
FREE Resource
15 Slides • 20 Questions
1
Open Ended
In computing, what is a variable? (3 Minutes)
2
Remember ....
A variable is a named storage location in memory that holds a value which can change while the program is executed.
By naming a variable, you can access the data assigned to it easily throughout the program.
A variable can hold one value (piece of data) at a time. This value can change throughout the execution of a program. When a new value is placed in (or assigned to) a variable, it replaces the last value.
By Mr. Dwedari
3
Identify the variables within a program.
Understand data types
Identify and describe what a program does.
Debug a program
Learning Objectives:
Some text here about the topic of discussion
4
What do you think this program does and why?
Think, Pair, Share ....
By Mr. Dwedari
personName = "Mr Shaw"
print(personName)
5
Explanation ...
What do you think this program does?
By Mr. Dwedari
This is the variable identifier --->personName = "Mr Shaw"
print(personName)<---This prints the value stored
in the variable
6
Try another one...
What is the variable in this program? What would it print out?
x = "Mr Shaw"
print("x")
7
Multiple Choice
Identify the variables in the program?
x = "Mr Shaw"
print("x")
x
Mr Shaw
"x"
"Mr Shaw"
8
Multiple Select
Identify the variables in the program:
x = "this is message one"
y = "5"
print(x, y)
x
this is message one
y
5
9
This is a variable. ---->x = "this is message one"<----Data type and value
This is a variable. ----> y = "5" <----Data type and value
Explanation
Identify the variables in the program:
print(x, y)
10
x = "this is message one"
y = "5"
print(x, y)
What will the last line output?
11
Multiple Choice
What will be displayed using
x = "this is message one"
y = "5"
print(x, y)
x, y
"x,y"
this is message one 5
error
12
Multiple Choice
In Python, you can assign different types of data to variables, and the choice of data type is crucial because it determines how the data is stored and what kind of operations can be performed on it.
False
True
13
Examples:
x = "My name is Oscar"
y = 8.4
age = 18
Mobile = "+447751234567"
postcode= "M46 1AA"
s = "18"
answer= False
Note: With Boolean variables, the first letters of True or False must be in uppercase
Data Types
Different types of data can be assigned to variables
<<< String (a sequence of letters, numbers and/or symbols)
14
Examples:
x = "My name is Oscar"
y = 8.4
age = 18
Mobile = "+447751234567"
postcode= "M46 1AA"
s = "18"
answer= False
Note: With Boolean variables, the first letters of True or False must be in uppercase
Data Types
Different types of data can be assigned to variables
<<< String (a sequence of letters, numbers and/or symbols)
<<< Float/ Real (a number with decimal point)
15
Examples:
x = "My name is Oscar"
y = 8.4
age = 18
Mobile = "+447751234567"
postcode= "M46 1AA"
s = "18"
answer= False
Note: With Boolean variables, the first letters of True or False must be in uppercase
Data Types
Different types of data can be assigned to variables
<<< String (a sequence of letters, numbers and/or symbols)
<<< Float/ Real (a number with decimal point)
<<< Integer (a whole number)
16
Examples:
x = "My name is Oscar"
y = 8.4
age = 18
Mobile = "+447751234567"
postcode= "M46 1AA"
s = "18"
answer= False
Note: With Boolean variables, the first letters of True or False must be in uppercase
Data Types
Different types of data can be assigned to variables
<<< String (a sequence of letters, numbers and/or symbols)
<<< Float/ Real (a number with decimal point)
<<< Integer (a whole number)
<<< String
17
Examples:
x = "My name is Oscar"
y = 8.4
age = 18
Mobile = "+447751234567"
postcode= "M46 1AA"
s = "18"
answer= False
Note: With Boolean variables, the first letters of True or False must be in uppercase
Data Types
Different types of data can be assigned to variables
<<< String (a sequence of letters, numbers and/or symbols)
<<< Float/ Real (a number with decimal point)
<<< Integer (a whole number)
<<< String
<<< String
18
Examples:
x = "My name is Oscar"
y = 8.4
age = 18
Mobile = "+447751234567"
postcode= "M46 1AA"
s = "18"
answer= False
Note: With Boolean variables, the first letters of True or False must be in uppercase
Data Types
Different types of data can be assigned to variables
<<< String (a sequence of letters, numbers and/or symbols)
<<< Float/ Real (a number with decimal point)
<<< Integer (a whole number)
<<< String
<<< String
<<< String (whole number but surrounded by " ". Therefore it is String )
19
Examples:
x = "My name is Oscar"
y = 8.4
age = 18
Mobile = "+447751234567"
postcode= "M46 1AA"
s = "18"
answer= False
Note: With Boolean variables, the first letters of True or False must be in uppercase
Data Types
Different types of data can be assigned to variables
<<< String (a sequence of letters, numbers and/or symbols)
<<< Float/ Real (a number with decimal point)
<<< Integer (a whole number)
<<< String
<<< String
<<< String (whole number but surrounded by " ". Therefore it is String )
<<< Boolean (only False/True can be assigned to this variable)
20
Multiple Choice
The type of a variable could be string if the data assigned to it were a ....
a sequence of letters, numbers and/or symbols
whole number
digits/numbers with a decimal point
21
Multiple Choice
The type of a variable could be an float/Real if the data assigned to it were a ....
a sequence of letters, numbers and/or symbols
whole number
digits/numbers with a decimal point
True/False
22
Multiple Choice
The type of a variable could be an integer if the data assigned to it were a ....
a sequence of letters, numbers and/or symbols
whole number
digits/numbers with a decimal point
False/True
23
Multiple Choice
The type of a variable could be an Boolean if the data assigned to it were a ....
a sequence of letters, numbers and/or symbols
whole number
digits/numbers with a decimal point
False/True
24
Multiple Choice
What is the data type of the variable a in this program:
a=25
print(a)
Float/Real
Boolean
String
Integer
25
Multiple Choice
What is the data type of the variable a in this program:
a=2.5
print(a)
Float/Real
Boolean
String
Integer
26
Multiple Choice
What is the data type of the variable x in this program:
x = True
print(x)
Float/Real
Boolean
String
Integer
27
Multiple Choice
What is the data type of the variable x in this program:
x = "3.25"
print(x)
Float/Real
Boolean
String
Integer
28
Multiple Choice
What is the data type of the variable b in this program:
b = "True"
print(b)
Float/Real
Boolean
String
Integer
29
Multiple Choice
What is the data type of the variable Tel in this program:
Tel = "+447788123450"
print(Tel)
Float/Real
Boolean
String
Integer
30
Multiple Choice
Use Python Online to test the following code then answer the question (5 minutes)
Tel = "+447788123450"
print("Tel")
What is the output of this program:
"+447788123450"
+447788123450
Tel
tel
31
Multiple Choice
What will the be the output of following code?
x = 7
x = x+1
print(x)
8
x + 1
7
x
32
Multiple Choice
Predict ....
What will the following code display in the shell?
x = 7
y = 4
print(x, "+", y,"=", x+y)
Error
7 + 4 = 11
x + y = 11
74
33
Multiple Choice
Use Python Online to test the following code then answer the question (5 minutes)
What will the following code display in the shell?
x = 7
y = 4
print(x, "+", y,"=", x+y)
error
7 + 4 = 11
x + y = 11
74
34
Multiple Choice
What will be the output of the following code ? (1-minute)
x = 7
y = 4
print(x, "x", y,"=", x*y)
74
7 x 4 = 28
x x y = 11
7777
35
Thank you!
By Mr. Dwedari
In computing, what is a variable? (3 Minutes)
Show answer
Auto Play
Slide 1 / 35
OPEN ENDED
Similar Resources on Wayground
30 questions
ESB Domain 2 Lesson 2 - Aspects of Marketing Processes
Presentation
•
9th Grade
31 questions
Troubleshooting
Presentation
•
9th - 10th Grade
27 questions
One-dimensional Lists
Presentation
•
9th - 10th Grade
27 questions
ICT Applications
Presentation
•
9th - 10th Grade
29 questions
Hexadecimal
Presentation
•
9th - 10th Grade
26 questions
Lesson 2 g9 1.2 Obtain Correct Specifications
Presentation
•
9th Grade
25 questions
Trace Tables
Presentation
•
9th - 10th Grade
30 questions
Solving Quadratics by Square Roots
Presentation
•
9th - 10th Grade
Popular Resources on Wayground
10 questions
HCS SCI 03 Summer School Review 4
Quiz
•
3rd Grade
11 questions
HSMS - Standard Response Protocol
Quiz
•
6th - 8th Grade
16 questions
1.1-1.2 Quiz Review
Quiz
•
9th - 12th Grade
12 questions
Exponent Expressions
Quiz
•
6th Grade
20 questions
Adding and Subtracting Integers
Quiz
•
6th - 7th Grade
11 questions
Northeast States
Quiz
•
3rd - 4th Grade
10 questions
Characterization
Quiz
•
3rd - 7th Grade
10 questions
Common Denominators
Quiz
•
5th Grade