What are the assignment operators?

  • b = a
  • b += a
  • b -= a
  • b *= a
  • b /= a
  • b %= a
  • b **= a
  • b //= a
#examples
b = 1

b+=2
print("1. ",b)
b-=1
print("2. ",b)
b*=30
print("3. ",b)
b/=6
print("4. ",b)
b%=7
print("5. ",b)
b**=2
print("6. ",b)
b//=4
print("7. ",b)

#output
1. 3
2. 2
3. 60
4. 10.0
5. 3.0
6. 9.0
7. 2.0

Advertisements