Python Operators MCQ Quiz - MCQ Questions and Answers

Welcome to our "Python Operators MCQ Quiz - MCQ Questions and Answers" blog post! This carefully curated quiz is designed for learners and professionals who wish to test and reinforce their understanding of Python operators. Operators in Python are fundamental building blocks, allowing you to perform operations on variables and values. Our quiz covers a wide range of topics, from basic arithmetic operators to more complex logical and bitwise operators. 

 Each question is crafted to challenge your knowledge and enhance your understanding of how different operators work in Python. This includes questions on operator precedence, the use of operators in various contexts, and understanding the nuances that come with Python’s implementation of these operators. Whether you're a beginner looking to get a solid footing or a seasoned programmer aiming to brush up your skills, this quiz will provide a comprehensive and engaging way to assess your knowledge. Let’s get started and test your mastery of Python operators!

1. What is the result of 8 % 3?

a) 2
b) 2.67
c) 3
d) 5

Answer:

a) 2

Explanation:

The % operator returns the remainder of the division. 8 divided by 3 leaves a remainder of 2.

2. What does the '//' operator do in Python?

a) Performs floating-point division
b) Performs floor division
c) Divides and assigns the value
d) Checks if the numbers are divisible

Answer:

b) Performs floor division

Explanation:

The '//' operator performs floor division, which divides and then rounds down to the nearest integer.

3. Which operator has the highest precedence in Python?

a) **
b) *
c) +
d) //

Answer:

a) **

Explanation:

The exponentiation operator (**) has the highest precedence in Python.

4. What is the output of 3 ** 2?

a) 6
b) 9
c) 5
d) 8

Answer:

b) 9

Explanation:

The ** operator performs exponentiation. 3 squared equals 9.

5. What does the 'not' operator do?

a) Negates a boolean value
b) Checks if two values are not equal
c) Reverses the order of characters
d) All of the above

Answer:

a) Negates a boolean value

Explanation:

The 'not' operator is used to negate a boolean value in Python.

6. What is the result of 'Python' == 'Python'?

a) True
b) False
c) Error
d) None

Answer:

a) True

Explanation:

The '==' operator checks if the values on either side are equal. Here, both strings are identical.

7. What is the purpose of the 'is' operator?

a) To compare values
b) To check if two variables point to the same object
c) To check if the type of two variables is the same
d) To check for equality of values and types

Answer:

b) To check if two variables point to the same object

Explanation:

The 'is' operator checks if two variables refer to the same object in memory.

8. What does the following expression return: not(3 > 1)?

a) True
b) False
c) Error
d) None

Answer:

b) False

Explanation:

Since 3 is greater than 1, the expression inside the parentheses is True, and the 'not' operator negates it to False.

9. What is the output of 'Hello' + 'World'?

a) HelloWorld
b) Hello World
c) Error
d) None

Answer:

a) HelloWorld

Explanation:

The '+' operator concatenates strings.

10. What is the result of 10 >> 2?

a) 2
b) 4
c) 5
d) 8

Answer:

c) 5

Explanation:

The >> operator is the right shift operator, shifting bits of 10 (1010 in binary) 2 places to the right, resulting in 5 (0101 in binary).

11. Which operator is used for membership testing?

a) ==
b) in
c) ::
d) is

Answer:

b) in

Explanation:

The 'in' operator is used to check if a value is a member of a sequence.

12. What is the output of the expression: 3 * 1 ** 3?

a) 0
b) 1
c) 3
d) 9

Answer:

c) 3

Explanation:

According to operator precedence, exponentiation is done first (1 ** 3 = 1), then multiplication (3 * 1).

13. How do you check if 'a' does not equal 'b' in Python?

a) a <> b
b) a != b
c) a =! b
d) not a = b

Answer:

b) a != b

Explanation:

The '!=' operator is used to check if two values are not equal.

14. What is the output of 2 & 3?

a) 1
b) 2
c) 3
d) 0

Answer:

b) 2

Explanation:

The & operator performs a bitwise AND operation. 2 (010 in binary) & 3 (011 in binary) results in 010, which is 2.

15. What does the 'or' operator do?

a) Returns True if at least one operand is true
b) Returns True if both operands are true
c) Returns the first false value
d) None of the above

Answer:

a) Returns True if at least one operand is true

Explanation:

The 'or' operator returns True if either of the operands is True.

16. What is the result of the expression: 'Python' and 'Programming'?

a) Python
b) Programming
c) True
d) False

Answer:

b) Programming

Explanation:

When using the 'and' operator, if both values are true, the last value is returned.

17. How does the += operator work?

a) Adds two values
b) Adds right operand to the left operand and assigns the result to left operand
c) Increments a variable
d) None of the above

Answer:

b) Adds right operand to the left operand and assigns the result to left operand

Explanation:

The += operator is a shorthand for performing addition and assignment in one step.

18. What is the output of [1, 2, 3] * 2?

a) [1, 2, 3, 1, 2, 3]
b) [2, 4, 6]
c) [1, 2, 3]
d) Error

Answer:

a) [1, 2, 3, 1, 2, 3]

Explanation:

The * operator, when used with lists, repeats the list the specified number of times.

19. What is the result of 'a' < 'b'?

a) True
b) False
c) Error
d) None

Answer:

a) True

Explanation:

Python compares strings lexicographically, and 'a' is less than 'b'.

20. What does the expression 5 | 3 evaluate to?

a) 8
b) 7
c) 6
d) 5

Answer:

b) 7

Explanation:

The | operator performs a bitwise OR operation. 5 (101 in binary) | 3 (011 in binary) results in 111, which is 7.

Comments