Hands On Exercise

Congratulations on completing this lesson on Python operators. Test your knowledge through these short snippets and get one step closer to mastering Python!

Exercise 1

Guess the results of performing the following operations and then run the code below to see the actual output!

Press + to interact
a = 10
a += 5
print(a)
b = 20
b -= a
print(b)
print (a < b)

Exercise 2

Question: What will the result of performing a single left shift on 0101010 be?

Exercise 3

Question: What is the difference between the = and the == operators?

Exercise 4

Keeping in mind the precedence rules, dry run the expression below. You can find the expression’s answer by running the code and comparing it to your own!

Press + to interact
​​mathematical_expression = 2 + (20 - 5) // 5
print(mathematical_expression)