Monday, June 10, 2019

Assignment operators in Python

Assignment operators in Python



# Assignment operators in Python
# Operator Example Equivalent to
# = x = 5 x = 5
# += x += 5 x = x + 5
# -= x -= 5 x = x - 5
# *= x *= 5 x = x * 5
# /= x /= 5 x = x / 5
# %= x %= 5 x = x % 5
# //= x //= 5 x = x // 5
# **= x **= 5 x = x ** 5
# &= x &= 5 x = x & 5
# |= x |= 5 x = x | 5
# ^= x ^= 5 x = x ^ 5
# >>= x >>= 5 x = x >> 5
# <<= x <<= 5 x = x << 5

a = 10
b = 20
c = 0

print ("a value is ",a)
print ("b value is ",b)
print ("c value is ",c)

c = a + b
print (" Value of c is (c=a+b) ", c)

c += a
print (" Value of c is (c +=a)", c)

c *= a
print (" Value of c is (c *=a)", c)

c /= a
print (" Value of c is (c /=a)", c)

c  = 2
c %= a
print (" Value of c is (c %=a)", c)

c **= a
print (" Value of c is (c **= a)    ", c)

c //= a
print (" Value of c is (c //=a)", c)


1 comment:

  1. I must appreciate you for providing such a valuable content for us. I found so many interesting stuff in your blog Helped a lot in increasing my knowledge Amazon bellen

    ReplyDelete

Wireless Security Configuration: Protect Your Network Now!

Introduction: In today’s connected world, wireless networks are as common as smartphones, and they’re often the gateway to our personal, pr...