Variables Questions and Answers
Practice ModeShowing 10 of 24 questions
Q11
How do you delete a variable in Python?
Answer: Option C
Explanation: The del statement removes variable references from memory.
Q12
What is the output of: a = [1, 2, 3]; b = a; b[0] = 5; print(a)?
Answer: Option B
Explanation: Lists are mutable and assignment creates a reference, not a copy.
Q13
Which of these is an immutable data type in Python?
Answer: Option C
Explanation: Tuples are immutable, meaning their values cannot be changed after creation.
Q14
What does the None keyword represent in Python?
Answer: Option C
Explanation: None is a special constant representing the absence of a value.
Q15
How do you create a constant variable in Python?
Answer: Option D
Explanation: Python doesn't have built-in constants, but uppercase naming convention is used.
Q16
What is variable shadowing in Python?
Answer: Option B
Explanation: Variable shadowing occurs when a local variable has the same name as a global variable.
Q17
Which function converts a string to an integer in Python?
Answer: Option B
Explanation: int() function converts strings and other types to integers.
Q18
What is the lifetime of a local variable in Python?
Answer: Option B
Explanation: Local variables exist only during function execution.
Q19
How do you check if a variable is defined in Python?
Answer: Option C
Explanation: The locals() and globals() functions contain current variable definitions.
Q20
What is the difference between = and == in Python?
Answer: Option C
Explanation: = is for assignment, == is for equality comparison.