Python Operators Questions and Answers
Practice ModeShowing 10 of 26 questions
Q1
What is the output of 5 ** 2 in Python?
Answer: Option B
Explanation: The ** operator is used for exponentiation in Python. 5 ** 2 means 5 raised to the power of 2, which equals 25.
Q2
Which operator is used for floor division in Python?
Answer: Option B
Explanation: Floor division returns the largest integer that is less than or equal to the division result. The // operator is used for floor division in Python.
Q3
What does the % operator do in Python?
Answer: Option C
Explanation: The % operator is the modulus operator that returns the remainder of division operation.
Q4
What is the result of 10 // 3?
Answer: Option B
Explanation: Floor division (//) returns the largest integer less than or equal to the result. 10 รท 3 = 3.333, so floor division gives 3.
Q5
Which operator has the highest precedence in Python?
Answer: Option C
Explanation: Parentheses have the highest precedence in Python and can be used to force an expression to evaluate in the order you want.
Q6
What is the output of "hello" * 3?
Answer: Option B
Explanation: The * operator can be used with strings to repeat them multiple times. "hello" * 3 repeats "hello" three times.
Q7
Which operator is used for identity comparison?
Answer: Option C
Explanation: The "is" operator checks if two variables point to the same object in memory, while "==" checks if values are equal.
Q8
What is the result of 15 % 4?
Answer: Option B
Explanation: The modulus operator (%) returns the remainder of division. 15 รท 4 = 3 with remainder 3.
Q9
Which operator performs bitwise AND operation?
Answer: Option C
Explanation: The & operator performs bitwise AND operation on integers, comparing each bit position.
Q10
What does the += operator do?
Answer: Option C
Explanation: The += operator is an augmented assignment operator that adds the right operand to the left operand and assigns the result to the left operand.