Page 52 - Computer - 7
P. 52
Example
Operator Name Description Output
(X = 20, Y = 3)
* Multiplication Multiplies two numeric values. X * Y 60
/ Division Divides the first number by the second. X / Y 6.66
Modulus Divides the first number by the second
% X % Y 2
(Remainder) and returns the remainder.
Exponentiation Raises the first number to the power
** X ** Y 800
(Power) represented by the second number.
Integer (floor) Divides the first number by the second
// X // Y 6
division and returns the integer quotient.
Lab Activity 3
Experiential Learning
Program to accept two numbers from the user and display the result of various arithmetic operations
on them.
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.
Assignment Operator
The Assignment operator is used to assign a value to a variable. Python provides several types of
Assignment operators, which are described in the table given below.
Operator Name Description
= Assignment Assigns the value on right side to the variable on the left side.
Addition Adds the value on the right side to the value on the left side and assigns
+=
Assignment it to the variable on the left side. X += 2 is same as X = X + 2.
Subtraction Subtracts the value on the right side from the value on the left side and
–=
Assignment assigns it to the variable on the left side. X –= 3 is same as X = X – 3.
50