Page 53 - Computer - 7
P. 53
Operator Name Description
Multiplication Multiplies the value on the right side to the value on the left side and
*=
Assignment assigns it to the variable on the left side. X *= 5 is same as X = X * 5.
Division Divides the value on the right side by the value on the left side and
/=
Assignment assigns it to the variable on the left side. X /= 4 is same as X = X / 4.
Lab Activity 4 Experiential Learning
Program to illustrate the use of Assignment operators.
1. Type the code as shown in the image in the Python Editor.
2. Press the F5 key to execute the code. Sample output of the program is given.
Relational Operators
Relational operators are used to compare two values or expressions. They are also known as Comparison
operators. The result of these operators is either True or False. The Relational operators available in
Python are described in the table given below.
Example
Operator Name Description Output
(X = 9, Y = 6)
If the values compared are equal, returns
== Equal to X == Y False
True, else returns False.
If the values compared are unequal, returns
!= Not equal to X != Y True
True, else returns False.
If the first value is greater than the second,
> Greater than X > Y True
returns True, else returns False.
If the first value is less than the second,
< Less than X < Y False
returns True, else returns False.
If the first value is greater than or equal
Greater than
>= to the second, returns True, else returns X >= Y True
or equal to
False.
Less than or If the first value is less than or equal to the
<= X <= Y False
equal to second, returns True, else returns False.
51