0% found this document useful (0 votes)
6 views

STD VIII - Arithmetic Operators

Uploaded by

Rishta Porwal
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

STD VIII - Arithmetic Operators

Uploaded by

Rishta Porwal
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

ARYA VIDYA MANDIR GROUP OF SCHOOLS

STD VIII- COMPUTERS

Arithmetic operators

Arithmetic operators are used to perform mathematical operations like addition,


subtraction, multiplication etc.
Operator Meaning Example

+ Add two operands or unary plus x + y +2

- Subtract right operand from the left or unary minus x - y -2

* Multiply two operands x*y

/ Divide left operand by the right one (always x/y


results into float)

% Modulus - remainder of the division of left x%y


operand by the right (remainder
of x/y)

// Floor division - division that results into x // y


whole number adjusted to the left in the
number line
** Exponent - left operand raised to the power of right x**y (x to
the power
y)

Example #1: Arithmetic operators in Python


script.pyPython Shell
x = 15
y=4
print('x + y =',x+y)
print('x - y =',x-y)
print('x * y =',x*y)
print('x / y =',x/y)
print('x // y =',x//y)
print('x ** y =',x**y)

When you run the program, the output will be:

x + y = 19
x - y = 11
x * y = 60
x / y = 3.75
x // y = 3
x ** y = 50625

Order of Precedence
Precedence is used to determine the order of evaluation of an expression involving more
than one operator.
The order is:
I) ( ) - Parenthesis (Rounded brackets)
I) *, /, %, // ( Left to right -whichever comes first)
II) +, - (Left to right after calculation of *,/,%)

Evaluate the following expression:


12 + 3 * 4 - 6 / 2 (12 + 3 ) * 4 - 6 / 2 12 + 3 * (4 - 6 ) / 2

12 + 12 – 3.0 15 * 4 - 6 / 2 12+ 3 * ( -2 ) / 2
24 -3.0 60 - 6 / 2 12 - 6 / 2
21.0 Answer 60 - 3.0 12- 3.0
57.0 Answer 9.0 Answer

Exercise :
Q. 1 Evaluate the following expression:
a) 37/(5*2)
b) 37/5/2
c) 37* (5/2)
d) 37%(5%2)
e) 37%5%2
f) 37-5 *2

Q.2 Evaluate the following: when a= 15, b=5, c= 2


i) a / b *c
ii) (a+b) * c
iii) a + b % 2
iv) a / b – c
v) a % (b - c)
vi) a + b - c

You might also like