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

Ethical Hacking Techniques: Cracking WPA/WPA2 Wi-Fi Using WPS and Capturing Handshakes

In the realm of cyber security, ethical hacking plays a crucial role in identifying and addressing vulnerabilities. One of the areas where e...