Operators in Python are special symbols and keywords used to manipulate data, perform mathematical computations, make boolean comparisons, and control execution logic. Beyond fundamental arithmetic (+, -, *, /, //, %, **), Python includes advanced operators like the assignment expression walrus operator (:=), matrix multiplication (@), dictionary union operators (| and |=), and bitwise operators (&, |, ^, ~, <<, >>). Understanding operator evaluation order, short-circuit behavior in logical operations (and, or), identity versus equality (is vs ==), and sequence repetition is essential for writing efficient Python code and passing modern technical assessments.
Latest Python Operators MCQs
1 min read
Correct Answer: b) 3
Explanation:
The floor division operator (//) divides two numbers and rounds down to the nearest integer. Since both operands are integers, the result is an integer.
Correct Answer: c) -4
Explanation:
Python performs floor division by rounding down toward negative infinity. -10 / 3 equals -3.333..., which floors down to -4.
Correct Answer: c) ** (Exponentiation)
Explanation:
Exponentiation (**) has a higher precedence than arithmetic multiplication/addition and comparison operators in Python.
Correct Answer: b) 512
Explanation:
The exponentiation operator (**) groups right-to-left. Therefore, 2 ** 3 ** 2 is evaluated as 2 ** (3 ** 2) = 2 ** 9 = 512.
Correct Answer: d) -2
Explanation:
In Python, the modulo operator result takes the sign of the divisor. Using the formula r = a - (b * (a // b)): 7 - (-3 * (7 // -3)) = 7 - (-3 * -3) = 7 - 9 = -2.
Correct Answer: b) is
Explanation:
The identity operator 'is' evaluates to True if both variables point to the exact same object memory location, whereas '==' compares values.
Correct Answer: b) True and False
Explanation:
The two list instances have identical values, so '==' returns True. However, lists are mutable so Python creates two separate object instances, making 'is' return False.
Correct Answer: a) True
Explanation:
The membership operator 'in' checks for keys when used directly on a dictionary in Python.
Correct Answer: b) False
Explanation:
The values inside the dictionary are strings ('a', 'b'), not the integer 1. Therefore, searching for 1 in dict.values() returns False.
Correct Answer: a) 1
Explanation:
Bitwise AND (&) compares binary representations. 5 is 0101 in binary and 3 is 0011. Performing bitwise AND gives 0001, which is 1.
Correct Answer: b) 7
Explanation:
Bitwise OR (|) computes 0101 | 0011 = 0111 in binary, which equals 7 in decimal.
Correct Answer: c) 6
Explanation:
Bitwise XOR (^) returns 1 where bits differ. 0101 ^ 0011 = 0110 in binary, which evaluates to 6 in decimal.
Correct Answer: b) -6
Explanation:
The bitwise NOT operator (~) returns ~x = -(x + 1). Hence, ~5 yields -(5 + 1) = -6.
Correct Answer:
Correct Answer: b) Assigns values to variables as part of a larger expression.
Explanation:
Introduced in Python 3.8, the walrus operator (:=) enables value assignment directly inside expressions (e.g., inside while loops or conditional statements).
Correct Answer: b) 'Hello'
Explanation:
The logical 'or' operator evaluates operands from left to right and returns the first truthy value encountered without evaluating the remaining operands.
Correct Answer: a) ''
Explanation:
The logical 'and' operator returns the first falsy value it encounters. Since the empty string '' is falsy, it is returned directly.
Correct Answer: d) 'Python'
Explanation:
The 'or' operator checks operands until it finds a truthy value. Since 0, False, and [] are all falsy, it proceeds to and returns 'Python'.
Correct Answer: b) 4
Explanation:
In Python, bool is a subclass of int where True equals 1. With precedence rules, True * 3 is 1 * 3 = 3, and True + 3 becomes 1 + 3 = 4.
Correct Answer: a) True
Explanation:
Python supports chained comparisons. 10 > 5 > 2 is evaluated as (10 > 5) and (5 > 2), which is True and True = True.
Correct Answer: a) True
Explanation:
Python performs implicit type promotion when comparing integers and floats, so the integer 1 and float 1.0 are considered equal in value.
Correct Answer: b) False
Explanation:
The 'is' operator checks for object identity (memory location and type). Int and float objects are distinct types stored separately in memory.
Correct Answer: b) __add__
Explanation:
The special magic method __add__(self, other) is used to define or override the behavior of the addition operator (+).
Correct Answer: b) __radd__
Explanation:
The __radd__ method is called when the left operand does not implement __add__ or returns NotImplemented.
Correct Answer: b) __iadd__
Explanation:
The __iadd__ method implements in-place addition assignment (+=).
Correct Answer: b) 11
Explanation:
The right side of the assignment (3 * 2 = 6) is evaluated first. Then x += 6 evaluates to 5 + 6 = 11.
Correct Answer: b) 'Python'
Explanation:
When applied to strings, the + operator performs sequence concatenation.
Correct Answer: b) [1, 2, 1, 2, 1, 2]
Explanation:
When a list is multiplied by an integer n, the list is repeated n times into a single flat list.
Correct Answer: c) True
Explanation:
The integer 0 is evaluated as falsy in a boolean context. Negating it with 'not' yields True.
Correct Answer: b) False
Explanation:
'False' is a non-empty string, making it truthy. Negating a truthy value returns False.
Correct Answer: b) 1.0
Explanation:
If either operand in floor division is a float, the result is returned as a float rounded down (1.0).
Correct Answer: b) 5.0
Explanation:
The single slash (/) operator in Python 3 always performs true division and returns a floating-point number.
Correct Answer: b) ::
Explanation:
The '::' symbol is used in slicing notation, but it is not classified as an independent stand-alone Python operator.
Correct Answer: b) False
Explanation:
This expression is chained as (3 < 4) and (4 == True). While 3 < 4 is True, 4 == True evaluates to False, making the overall result False.
Correct Answer: a) 5
Explanation:
The formula for ~x is -(x + 1). Applying this to -6 gives -(-6 + 1) = -(-5) = 5.
Correct Answer: b) False
Explanation:
Both empty list [] and empty string '' convert to False. False or False returns False.
Correct Answer: b) ==
Explanation:
The equality comparison operator (==) invokes the object's __eq__ method.
Correct Answer:
Correct Answer: a) True
Explanation:
Parentheses force (10 > 5) to evaluate first to True. Then True is True evaluates to True.
Correct Answer: a) __floordiv__
Explanation:
The __floordiv__(self, other) method handles the overload for floor division.
Correct Answer: a) __mod__
Explanation:
The __mod__ method defines the behavior of the % operator.
Correct Answer: a) (3, 1)
Explanation:
The divmod(a, b) function returns a tuple (a // b, a % b).
Correct Answer: a) __divmod__
Explanation:
The __divmod__ dunder method implements the built-in divmod() behavior for custom classes.
Correct Answer: b) False
Explanation:
10 and 10.0 are equal in value, so the inequality operator (!=) returns False.
Correct Answer: a) True
Explanation:
Strings are compared lexicographically using their Unicode scalar values (ord('a') = 97 < ord('b') = 98).
Correct Answer: b) False
Explanation:
In lexicographical string comparison, longer strings with matching prefixes are considered greater than shorter strings.
Correct Answer: a) True
Explanation:
Python compares sequences element-by-element in order. Since 3 < 4 at index 2, the result is True.
Correct Answer: c) Raises TypeError
Explanation:
Index 1 compares 'a' with 2. In Python 3, unorderable types (str vs int) throw a TypeError during comparison.
Correct Answer: b) False
Explanation:
Both bool(0) and bool(None) evaluate to False. False or False equals False.
Correct Answer: b) False
Explanation:
Due to floating-point representation limitations in IEEE 754 standard, 0.1 + 0.2 equals 0.30000000000000004, which is not equal to 0.3.
Correct Answer: a) math.isclose()
Explanation:
math.isclose(a, b) handles tiny precision rounding errors when comparing floating point numbers.
Correct Answer: b) 8
Explanation:
Right shifting by 1 bit effectively divides an integer by 2 (16 // 2 = 8).
Correct Answer: a) True
Explanation:
5 > 2 is True and 3 < 1 is False, so inner expression is False. 'not False' evaluates to True.
Correct Answer: b) Checks if object references point to different memory identities
Explanation:
'is not' tests identity negation (id(x) != id(y)).
Correct Answer: a) True
Explanation:
The 'in' membership operator checks if the left string exists as a substring of the right string.
Correct Answer: b) 2.0
Explanation:
5.5 // 2 evaluates floor division (2.75 floored to 2.0) and retains float type due to operand float type.
Correct Answer: b) -3.0
Explanation:
-5.5 / 2 = -2.75. Flooring toward negative infinity rounds down to -3.0.
Correct Answer: c) %
Explanation:
The modulus operator % calculates the remainder of division.
Correct Answer: b) 4
Explanation:
14 divided by 5 equals 2 with a remainder of 4.
Correct Answer: b) They return boolean True or False
Explanation:
Comparison operators in Python evaluate expressions and return boolean True or False.
Correct Answer: a) ^=
Explanation:
The ^= augmented assignment operator performs bitwise XOR and reassigns the result.
Correct Answer: a) True
Explanation:
min() is 1 and max() is 3. The comparison 1 < 3 evaluates to True.
Correct Answer: a) x = 5++
Explanation:
Python does not support post-increment (5++) or pre-increment (++var) operators found in C/C++. 5++ generates a SyntaxError.
Correct Answer: b) 5
Explanation:
Python parses ++5 as two unary positive operators: +(+5), which simply evaluates to 5.
Correct Answer: b) 5
Explanation:
Python interprets --5 as -(-5), applying unary minus twice, which evaluates to positive 5.
Correct Answer: b) __neg__
Explanation:
The __neg__ special method defines behavior for the unary negation operator.
Correct Answer: b) __pos__
Explanation:
The __pos__ special method overloads unary positive operator (+x).
Correct Answer: b) __abs__
Explanation:
The __abs__ special method defines behavior for the built-in abs() function.
Correct Answer: b) a if x else b
Explanation:
Python supports conditional expressions (ternary operator) using the syntax: 'value_if_true if condition else value_if_false'.
Correct Answer: a) 'pass'
Explanation:
Since the condition True holds, the conditional expression evaluates to the left value 'pass'.
Correct Answer: a) True
Explanation:
10 > 2 and 2 < 1 evaluates to False. Then False or (10 == 10) evaluates to True.
Correct Answer: b) False
Explanation:
10 < 20 is True. Applying 'not' to True produces False.
Correct Answer: a) True
Explanation:
Any non-zero numerical value evaluates to True in Python.
Correct Answer: b) False
Explanation:
float.is_integer() checks if the float instance represents an integer value. 0.5 has fractional components so it returns False.
Correct Answer: a) True
Explanation:
2.0 has zero fractional value, so float.is_integer() returns True.
Correct Answer: a) is
Explanation:
The identity operator 'is' and logical operators ('and', 'or', 'not') cannot be overridden by custom magic methods.
Related Posts
New
New
New

Latest Python Loops MCQs
Loops in Python provide the fundamental mechanism for executing a block of code repeatedly until a specified condition is met…
August 27, 2026By MCQs Generator

Python Variables & Data Types MCQs
Variables in Python act as dynamic references reserved in memory to store objects, operating without explicit data type declarations due…
August 27, 2026By MCQs Generator

Python Control Flow MCQs
Control flow statements regulate the order in which individual code statements are evaluated and executed in a Python program. Python…
August 27, 2026By MCQs Generator
Related Categories
New












AI & Data Science MCQ
5 topics
By MCQs Generator
New
Arts & Humanities MCQ
4 topics
By MCQs Generator
New
Civil Engineering MCQ
4 topics
By MCQs Generator
New
Commerce & Business MCQ
4 topics
By MCQs Generator
New
Competitive Exams MCQ
5 topics
By MCQs Generator
New
Electrical & Electronics Engineering MCQ
3 topics
By MCQs Generator
New
General Knowledge MCQ
2 topics
By MCQs Generator
New
General Science MCQ
4 topics
By MCQs Generator
New
Law & Judiciary MCQ
3 topics
By MCQs Generator
New
Mechanical Engineering MCQ
4 topics
By MCQs Generator
New
Medical & Health Sciences MCQ
4 topics
By MCQs Generator
New
Modern Tech Fields MCQ
3 topics
By MCQs Generator