WorksheetsPython Variables -Day 3
Total questions: 32
Worksheet time: 16mins
What is a variable?
programming
storage location
value
variable name
A Variable consists of...
VariableName and Value
Storage Location
IPO Chart and Flowchart
Programs
Algorithms
Which one is true:
Variables can change
Values can change
VariableNames can change
Data Types can change
Which one is true:
Values cannot change
Variable Name
Data Type
A variable can only hold one value at a time
Select all that are true for creating a VariableName
no spaces
start with a letter
each word starts with a capital letter
can only be a single word
same name used throughout
This programming concept allows programmers to create storage for data?
Control Strucutures
Variables
Selection Structures
Logic Operators
This operator assigns values. It also looks like an equal sign.
The boolean operator
The selection structure
The assignment operator
The logic operator
Which of this lines show the correct way to reassign a variable to a new value?
ironMAN=1000;
1000->ironMAN;
var ironMAN=1000;
1000 = ironMAN;
What is a variable?
A number that represents a shape
A letter that represents a number
A letter that represents a letter
I dont know
If t=5, what is 6+t
10
9
7
11
If p=7 What is px10
70
80
60
77
What are variables?
They are containers to store values of data.
They are a method to analyze data.
They are some commands.
They are names of types of data.
In computers science, variables:
are numbers like pi
represent parts of an experiment that are measured or tested
are placeholders for storing information
are unchangeable
Can I name my variable: Player1
True
False
I can name my variable: player 1 is the winner
True
False
I can name my variable: Player_1_is_the_best
True
False
Look at the following code:
name = "John"
age = 23
What type of data is stored in the variable name?
str
int
float
nothing
Look at the following code:
name = "John"
age = 23
What type of data is stored in the variable age?
str
int
float
nothing
If I want to store my height in a variable, which of the following would be a good variable name in best practice?
abcdefg
inches
number
height
If I want to store my name in a variable, which of the following would be a good variable name in best practice?
name
teacher
mister
abcdef
What rule is the following variable name BREAKING:
1st_Name
No special characters other than underscore
Only use text for the start of the variable name - no numbers at start
Keep names meaningful
There is nothing wrong with this variable name
What rule is the following variable name BREAKING?
StudentNo.
Only use text for the starting letter of a variable name - not numbers at the start
No special symbols other than the underscore
There is nothing wrong with this variable name
Keep variable names meaningful for the task they are being used for
what is the variable name in the following script?
name
hello, your name is
There is no variable in this script
Which name would be meaningful in keeping a record of someone's high score?
s
hs
score
highScore
Which of the below are acceptable variable names?
result final = 5
result-final = 1
resultFinal = 3
result#final = 4
What is a variable?
A location in memory that temporarily stores a value that your program can use later.
Data type
An ordered collection of items which can be of any data type
It is a command(function)
What is Python syntax for creating a variable and assigning the number 10 to it?
variable_name == 10
variable_name = 10
variable name = 10
def variable-name = 10
What happens when running the following code?
message = what a cool message!
print(message)
Python throws a SynthaxError because the string is not surrounded by quotes.
Python throws a NameError because the name is not defined properly.
“message” is printed.
“What a cool message!” gets printed to the console.
These are all valid variable names and assignments, EXCEPT:
user_name = “jdoe”
prompt21 = “Enter your user name”
43agents = False
userID = 100
