The following quiz provides Multiple Choice Questions (MCQs) related to Python Operators. This Python Quiz is also Interview (campus interview, walk-in interview, company interview), Placement or recruitment, entrance examinations, and competitive examinations oriented. You can practice these below questions to improve your python skills. You can click on the View Answer button to check the answer if you needed. Let’s solve this Python Operators (Multiple Choice Questions) MCQ – Python Interview objective questions| Python Quiz on Operators in python.
01. In the Python statement x = a + 5 – b:
a and b are ________
a + 5 - b is ________
- terms, a group
- operators, a statement
- operands, an expression
- operands, an equation
Answer : C Explanation: The objects that operators act on are called operands. An expression involving operators and operands is called an expression So, option C is correct.
02. Which is the correct operator for power(xy)?
- X^y
- X**y
- X^^y
- None of the mentioned
Answer : B Explanation: In python, power operator is x**y i.e. 2**5=32.
03. What is the output of the following addition (+) operator
a = [10, 20]
b = a
b += [30, 40]
print(a)
print(b)
- [10, 20, 30, 40] [10, 20, 30, 40]
- [10, 20] [10, 20, 30, 40]
- [10, 20, 10, 20] [10, 20, 30, 40]
- [10, 20] [30, 40]
Answer : A Explanation: Because since b and a reference to the same object, when we use the addition assignment operator += on b, it changes both a and b.
04. Which function overloads the >> operator?
- more()
- gt()
- ge()
- None of the above
Answer : D Explanation: rshift() function overloads the >> operator
05. What is the value of the expression 100 / 25?
- 4
- 4.0
- 0
- 25
Answer : B Explanation: The result of standard division is always float. The value of 100 // 25 (integer division) is 4.
06. Which one of these is floor division?
- //
- /
- %
- None of the above
Answer : A Explanation: When both of the operands are integer then python chops out the fraction part and gives you the round-off value, to get the accurate answer use, floor division. This is floor division. For ex, 5/2 = 2.5 but both of the operands are integers so the answer of this expression in Python is 2. To get the 2.5 as an answer, use floor division.
07. What is the output of the following assignment operator
a = 10
b = a -= 2
print(b)
- 8
- 10
- Syntax Error
- No error but no output too
Answer : C Explanation: b = a -= 2 expression is Invalid
08. Which operator is overloaded by the or() function?
- ||
- |
- //
- /
Answer : B Explanation: or() function overloads the bitwise OR operator “|”.
09. Should you use the == operator to determine whether objects of type float are equal?
- Nope, not a good idea.
- Sure! Go for it.
Answer : A Explanation: Internal representation of float objects is not precise, so they can’t be relied on to equal exactly what you think they will:>>> 1.1 + 2.2 == 3.3 False You should instead compute whether the numbers are close enough to one another to satisfy a specified tolerance:>>> tolerance = 0.00001 >>> abs((1.1 + 2.2) – 3.3) < tolerance True
10. What is the order of precedence in python?
i) Parentheses
ii) Exponential
iii) Multiplication
iv) Division
v) Addition
vi) Subtraction
- ii,i,iii,iv,v,vi
- ii,i,iv,iii,v,vi
- i,ii,iii,iv,vi,v
- i,ii,iii,iv,v,vi
Answer : A Explanation: For order of precedence, just remember this PEMDAS-Parentheses> Exponential> Multiplication> Division> Addition> Subtraction (similar to BODMAS).