Page 93 - modular4.0
P. 93
Chapter Profile
Operator Name Description Example
%= Remainder It takes modulus of two operands and assigns the result x %= 3
assignment to left operand. x%=3 is equivalent to x=x%3.
//= Floor division It performs floor division on operators and assigns the x //= 3
assignment value to the left operand. x//=3 is equivalent to x=x//3.
**= Exponentiation It performs exponential (power) calculation on x **= 3
assignment operators and assigns the value to the left operand.
x**=3 is equivalent to x=x**3.
Program 2: To perform all the assignment operators
Program2.py
File Edit Format Run Options Window Help
#Program to perform Assignment Operators
a = 21
b = 10
c = 0
c = a + b
print (c)
c +=a
print (c)
c -=a
print (c)
c *=a
print (c) Output
c /=a
31
print (c)
52
c=2
31
c %=a
print (c) 651
c **=a 31.0
print (c) 2
c //=a
2097152
Logical Operators
Logical operators are used to evaluate and decide. Python supports the following logical operators:
Operator Name Description Example (x=2) Output
and AND It returns true, if both operands are (x < 5) and (x < 10) TRUE
true.
Introduction to Programming 91

