**Example:**

## !/usr/bin/python

a = 21

b = 10

c = 0

c = a + b

print “Line 1 – Value of c is “, c

c += a

print “Line 2 – Value of c is “, c

c *= a

print “Line 3 – Value of c is “, c

c /= a

print “Line 4 – Value of c is “, c

c = 2

c %= a

print “Line 5 – Value of c is “, c

c **= a

print “Line 6 – Value of c is “, c

c //= a

print “Line 7 – Value of c is “, c

**Output:**

Line 1 – Value of c is 31

Line 2 – Value of c is 52

Line 3 – Value of c is 1092

Line 4 – Value of c is 52

Line 5 – Value of c is 2

Line 6 – Value of c is 2097152

Line 7 – Value of c is 99864

### Like this:

Like Loading...

*Related*

## Related Posts

80

Example: #!/usr/bin/python a = 60 # 60 = 0011 1100 b = 13 # 13 = 0000 1101 c = 0 c = a & b; # 12 = 0000 1100 print "Line 1 - Value of c is ", c c = a | b; # 61 = 0011… Tags: print, example, operators, python, operator

71

Operators are the constructs which can manipulate the value of operands. Consider the expression 4 + 5 = 9. Here, 4 and 5 are called operands and + is called operator. Types of Operator Python language supports the following types of operators. Python Arithmetic Operators Assume variable a holds 10… Tags: operators, python, operator

66

There are used to compare the memory locations of two operators. Example: #!/usr/bin/python a = 20 b = 20 if ( a is b ): print "Line 1 - a and b have same identity" else: print "Line 1 - a and b do not have same identity" if (… Tags: print, python, example, operators, operator

66

These operators compare the values on either sides of them and decide the relation among them. They are also called Relational operators. Example: #!/usr/bin/python a = 21 b = 10 c = 0 if ( a == b ): print "Line 1 - a is equal to b" else:… Tags: print, python, example, operator, operators

60

Example: #!/usr/bin/python a = 10 b = 20 list = [1, 2, 3, 4, 5 ]; if ( a in list ): print "Line 1 - a is available in the given list" else: print "Line 1 - a is not available in the given list" if ( b not… Tags: print, python, operators, example