Python Operators and Expression Quiz

This Python Operators and Expression Quiz. This quiz helps you to understand the concepts of Operators. Try to answer all questions. All The Best!!

1. What is the output of print(2 * 3 ** 3 * 4)

 
 

2. Which of the following operators has the highest precedence?

 
 
 

3. What is the output of the following code

x = 10
y = 5
print(x ** y)
print(x // y)

 

 
 
 

4. What is the output of the following addition (+) operator

a = [10, 20]
b = a
b += [30, 40]
print(a)
print(b)
 
 

5. What is the output of print(38 - 10 * 2)

 
 

6. What is the output of the following assignment operator

y = 10
x = y += 2
print(x)

 

 
 
 

7. Bitwise shift operators (<<>>) has higher precedence than Bitwise And(&) operator

 
 

8.

Which of the following operators has the lowest precedence?

 
 
 
 

9. What is the output of the following Python code

x = 10
y = 50
if (x ** 2 > 100 and y < 100):
    print(x, y)

 

 
 
 

10. What is the output of the following code

x = 10
y = 15
print(x and y)

 

 
 
 
 

11. What is the output of the expression  print(-18 // 4)

 
 
 
 

12. What is the value of the following Python Expression
print(6/3)

 
 

13. What is the output of print(2 ** 3 ** 2)

 
 

14. What is the output of the following program

i = 0
while i < 3:
       print(i)
       i++
       print(i+1)

 

 
 
 
 

15. What is the output of print(2%6)

 
 
 

16. What is the output of the following code

print(bool(0), bool(3.14159), bool(-3), bool(1.0+1j))

 
 
 
 

17. For two objects x and y:

  • x is y is True

    if and only if

  • id(x) == id(y)
 
 

18. Which function overloads the >> operator?

 
 
 
 

19. Is it safe to directly use the == operator to determine whether objects of type float are equal?

 
 

20. 4 is 100 in binary and 11 is 1011. What is the output of the following bitwise operators?

a = 4
b = 11
print(a | b)
print(a >> 2)

 

 
 

I hope you like this quiz. Share this python quiz with your friend.

Play more,

Support CodeSnail

If you appreciate my work, or if it has helped you along your journey. It would mean a lot to me if you could write a message on my wall and share a cup of coffee (or tea) with me.

Buy Me A Coffee

Related Articles

Your subscription could not be saved. Please try again.
Your subscription has been successful.

Newsletter

Subscribe to our newsletter and stay updated.

Leave a Comment

Copy link
Powered by Social Snap