Python Operators Questions and Answers

Practice Mode
Showing 10 of 26 questions
Q1
What is the output of 5 ** 2 in Python?
  • A 10
  • B 25
  • C 7
  • D Error
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?
  • A /
  • B //
  • C %
  • D |
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?
  • A Percentage
  • B Division
  • C Modulus (remainder)
  • D Multiplication
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?
  • A 3.333
  • B 3
  • C 4
  • D 1
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?
  • A ** (Exponentiation)
  • B * (Multiplication)
  • C () (Parentheses)
  • D + (Addition)
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?
  • A hello3
  • B hellohellohello
  • C Error
  • D hello hello hello
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?
  • A ==
  • B =
  • C is
  • D ===
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?
  • A 3.75
  • B 3
  • C 4
  • D 1
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?
  • A &&
  • B and
  • C &
  • D |
Answer: Option C
Explanation: The & operator performs bitwise AND operation on integers, comparing each bit position.
Q10
What does the += operator do?
  • A Addition only
  • B Assignment only
  • C Addition and assignment
  • D Equality check
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.
Questions and Answers for Competitive Exams Various Entrance Test