Python Operators (Multiple Choice Questions) MCQ – Python Interview objective questions| Python Quiz

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 ________
  1. terms, a group
  2. operators, a statement
  3. operands, an expression
  4. 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)?

  1. X^y
  2. X**y
  3. X^^y
  4. 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)
  1. [10, 20, 30, 40]
    [10, 20, 30, 40]
  2. [10, 20]
    [10, 20, 30, 40]
  3. [10, 20, 10, 20]
    [10, 20, 30, 40]
  4. [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?

  1. more()
  2. gt()
  3. ge()
  4. None of the above

Answer : D
Explanation: rshift() function overloads the >> operator

05. What is the value of the expression 100 / 25?

  1. 4
  2. 4.0
  3. 0
  4. 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?

  1. //
  2. /
  3. %
  4. 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)
  1. 8
  2. 10
  3. Syntax Error
  4. No error but no output too

Answer : C
Explanation: b = a -= 2 expression is Invalid

08. Which operator is overloaded by the or() function?

  1. ||
  2. |
  3. //
  4. /

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?

  1. Nope, not a good idea.
  2. 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

  1. ii,i,iii,iv,v,vi
  2. ii,i,iv,iii,v,vi
  3. i,ii,iii,iv,vi,v
  4. 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).

Leave a Reply