Q1. What is a variable in Python?
✅ Correct Answer: (C) A memory location used to store a value
📘 Explanation: A variable stores data values in memory and can change during program execution.
📘 Explanation: A variable stores data values in memory and can change during program execution.
Q2. Which of the following is a valid variable name in Python?
✅ Correct Answer: (C) value_1
📘 Explanation: Variable names can contain letters, numbers, and underscores but cannot start with a number or contain spaces/special symbols.
📘 Explanation: Variable names can contain letters, numbers, and underscores but cannot start with a number or contain spaces/special symbols.
Q3. Which symbol is used to assign a value to a variable in Python?
✅ Correct Answer: (B) =
📘 Explanation: The single equals sign = is used for assignment in Python.
📘 Explanation: The single equals sign = is used for assignment in Python.
Q4. Which of the following variable names is NOT valid?
✅ Correct Answer: (D) total-marks
📘 Explanation: Hyphen (-) is not allowed in Python variable names.
📘 Explanation: Hyphen (-) is not allowed in Python variable names.
Q5. Python is a ______ typed language.
✅ Correct Answer: (C) Dynamic
📘 Explanation: Python uses dynamic typing, so variable types are decided at runtime.
📘 Explanation: Python uses dynamic typing, so variable types are decided at runtime.
Q6. Which keyword is used to declare a variable in Python?
✅ Correct Answer: (D) None of the above
📘 Explanation: Python does not require a keyword to declare variables.
📘 Explanation: Python does not require a keyword to declare variables.
Q7. What will be the output of the following code?
x = 10
x = “Hello”
print(x)
✅ Correct Answer: (B) Hello
📘 Explanation: Python allows reassignment of variables to different data types.
📘 Explanation: Python allows reassignment of variables to different data types.
Q8. Which of the following is used to check the data type of a variable?
✅ Correct Answer: (B) type()
📘 Explanation: The type() function returns the data type of a variable.
📘 Explanation: The type() function returns the data type of a variable.
Q9. Which of the following is a case-sensitive variable name?
✅ Correct Answer: (C) Both A and B
📘 Explanation: Python is case-sensitive, so value, Value, and VALUE are different variables.
📘 Explanation: Python is case-sensitive, so value, Value, and VALUE are different variables.
Q10. What is the correct way to assign multiple values to variables?
✅ Correct Answer: (B) x, y = 1, 2
📘 Explanation: Python allows multiple assignment using x, y = 1, 2.
📘 Explanation: Python allows multiple assignment using x, y = 1, 2.
Q11. Which of the following statements is correct about Python variables?
✅ Correct Answer: (C) Variables can change their data type during execution
📘 Explanation: Python allows variables to be reassigned with values of different data types.
📘 Explanation: Python allows variables to be reassigned with values of different data types.
Q12. What will be the output of the following code?
a = 5
b = a
a = 10
print(b)
✅ Correct Answer: (A) 5
📘 Explanation: b gets the value of a at assignment time. Later changes to a do not affect b.
📘 Explanation: b gets the value of a at assignment time. Later changes to a do not affect b.
Q13. Which of the following is used to delete a variable in Python?
✅ Correct Answer: (C) del
📘 Explanation: The del keyword deletes a variable or object reference..
📘 Explanation: The del keyword deletes a variable or object reference..
Q14. What will be the output of the following code?
x = y = z = 100
print(x, y, z)
✅ Correct Answer: (C) 100 100 100
📘 Explanation: Python allows assigning the same value to multiple variables.
📘 Explanation: Python allows assigning the same value to multiple variables.
Q15. Which of the following cannot be used as a variable name?
✅ Correct Answer: (C) for
📘 Explanation: for is a Python keyword and cannot be used as a variable name.
📘 Explanation: for is a Python keyword and cannot be used as a variable name.
Q16. What will be the output?
x = 5
print(type(x))
✅ Correct Answer: (A) int
📘 Explanation: The type() function returns the class of the variable.
📘 Explanation: The type() function returns the class of the variable.
Q17. Which of the following statements about variable scope is TRUE?
✅ Correct Answer: (A) Global variables are accessible everywhere
📘 Explanation: Global variables can be accessed inside and outside functions.
📘 Explanation: Global variables can be accessed inside and outside functions.
Q18. What does the id() function return?
✅ Correct Answer: (B) Memory address of the object
📘 Explanation: id() returns the unique identity (memory location) of an object.
📘 Explanation: id() returns the unique identity (memory location) of an object.
Q19. Which of the following is an example of unpacking variables?
✅ Correct Answer: (B) x, y = 1, 2
📘 Explanation: Unpacking assigns multiple values to multiple variables in one statement.
📘 Explanation: Unpacking assigns multiple values to multiple variables in one statement.
Q20. What happens when a variable is assigned a new value in Python?
✅ Correct Answer: (C) Variable now refers to a new object
📘 Explanation: In Python, variables are references. Reassignment makes the variable point to a new object.
📘 Explanation: In Python, variables are references. Reassignment makes the variable point to a new object.