WorksheetsPYTHON -- variables
Total questions: 12
Worksheet time: 7mins
Variable names _____________.
Check all that apply.
must not begin with a number
can only contain the characters A-Z, a-z, 0-9, and _ .
letters must be lower case
letters can be upper case, but NOT at the beginning of the variable name
In Python, can string variables be declared using both single and double quotes?
i.e. name = "Ricky" OR name = 'Ricky'
Yes, they are interchangeable
No, only single quotes can be used
No, only double quotes can be used
No, strings cannot be declared with quotes
In Python, are variable names case-sensitive?
Yes, variable names are case-sensitive
No, variable names are not case-sensitive
Only the first character in the variable name is case-sensitive
Case sensitivity depends on the version of Python
In the following code, what value will be assigned to the variable "cat"?
mouse + cat + dog = "small" + "medium" + "large"
small, medium, large
small
medium
large
Nothing, that operation will throw an error
num = 90
num = 20
print(num)
90
4.5
20
1800
Which of the following options are valid variable names?
Check all that apply.
1st_name
first_name
first Name
f1_name
firstName
Variables are used _________.
to store data
to print data
to produce functions
What does the following Python program print?
x = "Hello World!"
y = "I can code "
z = " In Python"
print( x + y + z)
Hello World! I can code In Python
Hello World!I can code InPython
Hello World! I can codeIn Python
Hello World!I can code In Python
xyz
Why the following variable name invalid for python:
1st_Name = 153156456456415
It includes special characters other than underscore
The variable name starts with a number
Keep names meaningful
There is nothing wrong with this variable name
When each word of the variable name, except the first, starts with a capital letter, it's an example of ________.
Camel Case
Pascal Case
Snake Case
No Case
When each word of the variable name is separated by an underscore character, it's an example of ________.
Camel Case
Pascal Case
Snake Case
No Case
Which of the following options is NOT a valid variable name?
act2
myvar
quiz_3
Grade11A
