WorksheetsPython_Variables
Total questions: 9
Worksheet time: 5mins
In Python, a variable must be declared before it is assigned a value:
False
True
None
Which of the following statements assigns the value 100 to the variable x in Python:
x := 100
x = 100
x << 100
let x = 100
x <- 100
In Python, a variable may be assigned a value of one type, and then later assigned a value of a different type:
False
True
None
Consider the following sequence of statements:
n = 300
m = n
Following execution of these statements, Python has created how many objects and how many references?
Two objects, two references
One objects, two references
One objects, one references
Two objects, one references
What Python built-in function returns the unique number assigned to an object:
ref( )
identity( )
id( )
refnum( )
Which of the following are valid Python variable names:
router66
ver1.3
Age
return
home_address
You are reading Python code, and these statements appear scattered in different locations throughout the code:
employeenumber = 4398
.
.
.
EmployeeNumber = 4398
.
.
.
employeeNumber = 4398
These statements refer to different variables.
These statements refer to the same variable.
Which of the following styles does PEP8 recommend for multi-word variable names:
DistanceToNearestTown (Pascal Case)
distanceToNearestTown (Camel Case)
distance_to_nearest_town (Snake Case)
None
Which of the following are Python reserved words (keywords):
None
default
class
goto
and
