Font size
WorksheetsPython Variables Quiz
Total questions: 12
Worksheet time: 6mins
What are variables in Python used for?
Storing data values
Performing arithmetic operations
Controlling the flow of a program
Defining functions
How is a variable created in Python?
By using a special command
The moment you first assign a value to it
After declaring its type
By using the 'var' keyword
Do variables in Python need to be declared with a specific type before assigning a value?
Yes, always
No, they do not need to be declared with any particular type
Only for complex data types
Only for integer and string types
Can a variable in Python change type after it has been set?
Yes, it can change type
No, it cannot change type
It can only change to a related type
It can change type only once
What is the result of casting the integer 3 to a string in Python?
'3'
3
'3.0'
3.0
What will be the type of variable y after executing y = int(3) in Python?
str
int
float
list
How do you convert the number 3 to a floating-point number in Python?
(a)
Which Python function is used to determine the data type of a variable?
type()
typeof()
data_type()
get_type()
If x is assigned the value 5, what will be the output of print(type(x)) in Python?
If y is assigned the value "John", what will be the output of print(type(y)) in Python?
In Python, can string variables be declared using both single and double quotes?
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
Are variable names in Python 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
