Python Variables & Operators MCQs | 25 Practice Questions with Answers | CBSE Class 11 Computer Science
Class 11 · Computer Science
Python Variables & Operators MCQs (25 Questions)
Practice these multiple-choice questions to strengthen your understanding of Python Variables and Operators. Click Show Answer to reveal the correct answer and explanation.
Q1. What is a variable in Python?
A. A keyword
B. A storage location for data
C. A loop
D. A function
Show Answer
Answer: B. A storage location for data
Explanation: A variable is a named location used to store data that can be used and modified during program execution.
Q2. Which of the following is a valid variable name?
A. 2num
B. class
C. total_marks
D. first-name
Show Answer
Answer: C. total_marks
Explanation: Variable names cannot begin with a digit, contain hyphens, or be Python keywords.
Q3. Which symbol is used to assign a value to a variable?
A. ==
B. =
C. :=
D. :
Show Answer
Answer: B. =
Explanation: The assignment operator (=) assigns a value to a variable.
Q4. Which of the following is an integer data type?
A. 25
B. 25.5
C. "25"
D. True
Show Answer
Answer: A. 25
Explanation: A whole number without a decimal point is an integer.
Q5. Which function is used to determine the data type of a variable?
A. len()
B. type()
C. id()
D. value()
Show Answer
Answer: B. type()
Explanation: The type() function returns the data type of an object.
Q6. Which operator is used for addition?
A. +
B. -
C. *
D. /
Show Answer
Answer: A. +
Explanation: The + operator performs addition.
Q7. Which operator returns the remainder after division?
A. /
B. //
C. %
D. **
Show Answer
Answer: C. %
Explanation: The modulus operator (%) returns the remainder.
Q8. Which operator is used to calculate exponentiation?
A. ^
B. **
C. *
D. //
Show Answer
Answer: B. **
Explanation: The ** operator raises one number to the power of another.
Q9. What is the output of the following code?
print(10//3)
A. 3.33
B. 3
C. 4
D. 1
Show Answer
Answer: B. 3
Explanation: The floor division operator (//) returns the integer quotient.
Q10. Which operator is used to compare two values for equality?
A. =
B. ==
C. !=
D. >=
Show Answer
Answer: B. ==
Explanation: The equality operator (==) checks whether two values are equal.
Q21. What is the output of the following code?
a=10
b=20
print(a>b)
A. True
B. False
C. 10
D. Error
Show Answer
Answer: B. False
Explanation: Since 10 is not greater than 20, the expression evaluates to False.
Q22. What is the output of the following code?
x=5
y=10
print(x<10 and y>5)
A. True
B. False
C. Error
D. None
Show Answer
Answer: A. True
Explanation: Both conditions (x<10 and y>5) are true, so the result is True.
Q23. What is the output of the following code?
numbers=[10,20,30]
print(20 in numbers)
A. True
B. False
C. Error
D. None
Show Answer
Answer: A. True
Explanation: The value 20 exists in the list, so the membership operator returns True.
Q24. Which operator is used to compare object identity in Python?
A. ==
B. =
C. is
D. !=
Show Answer
Answer: C. is
Explanation: The is operator checks whether two variables refer to the same object in memory.
Q25. Which operator is used to calculate the remainder after division?
A. /
B. //
C. %
D. **
Show Answer
Answer: C. %
Explanation: The modulus operator (%) returns the remainder after division.
Answer Key
| Q.No. | Answer | Q.No. | Answer | Q.No. | Answer |
|---|---|---|---|---|---|
| 1 | B | 10 | B | 19 | B |
| 2 | C | 11 | C | 20 | B |
| 3 | B | 12 | A | 21 | B |
| 4 | A | 13 | C | 22 | A |
| 5 | B | 14 | C | 23 | A |
| 6 | A | 15 | C | 24 | C |
| 7 | C | 16 | C | 25 | C |
| 8 | B | 17 | B | ||
| 9 | B | 18 | C |
Practice Tips
- Choose meaningful and valid variable names that follow Python naming rules.
- Understand the difference between the assignment operator (
=) and the equality operator (==). - Practice arithmetic operators such as
+,-,*,/,//,%, and**. - Remember the purpose of logical operators:
and,or, andnot. - Differentiate between membership operators (
in,not in) and identity operators (is,is not). - Revise operator precedence to correctly evaluate complex expressions.
- Attempt the questions without viewing the answers first, then use the explanations to strengthen your understanding.