Python Program To Demonstrate Compound Operators
Write Python code to demonstrate compound operators
# WAP to demonstrate the use of compound operators. a = 7 print("The value of a is :", a) c = a print("c = a --> c =", c) c += a print("c += a --> c =", c) c -= a print("c -= a --> c =", c) c *= a print("c *= a --> c =", c) c //= a print("c //= a --> c =", c) c /= a print("c /= a --> c =", c) c %= a print("c mode a --> c =", c)
Output:
The value of a is : 7
c = a --> c = 7
c += a --> c = 14
c -= a --> c = 7
c *= a --> c = 49
c //= a --> c = 7
c /= a --> c = 1.0
c mode a --> c = 1.0