Assignment Operator

Code and Output

#= is assignment
x = 10
print (x)
#Output: 10
#+ is assignment with addition
a = 20
a += 100 #a = a + 100
print (a) #a = 20 +100
#Output: 120
#- is assignment with subtraction
b = 100
b -= 50 #b = b - 50
print (b) #b = 100 - 50
#Output: 50
#*= is assignment with multiplication
c = 10
c *= 2 #c = c * 2
print (c) #c = c 10 * 2
#Output: 20
#/= is assignment with division
d = 4
d /= 2 #d = d / 2
print (d) #d = d 4 / 2
#Output: 2
#**= is assignment with exponent
e = 2
e **= 2 #e = e ** 2
print (e) #e = e 2 ** 2
#Output:
#//= is assignment with floor division
f = 4
f //= 2 #f = f // 2
print (f) #f = f 4 // 2
#Output: 2
#%= is assignment with modulus division
g = 5
g %= 3 #g = g % 3
print (g) #g = g 5 % 3
#Output: 2








Comments

Popular posts from this blog

Data Validation

WDD - LO1 - MANAGE SECURE SITES