Operators and operands
Operators are special symbols that
represent computations like addition and multiplication. The values the
operator is applied to are called operands.
The
operators +, -, *, / and ** perform addition, subtraction, multiplication,
division and exponentiation.
Eg:
20+32
hour-1
hour*60+minute
minute/60
5**2
(5+9)*(15-7)
The order
of evaluation depends on the rules of
precedence. The acronym PEMDAS
is a useful way to remember the rules:
·
Parentheses
have the highest precedence
·
Exponentiation
has the next highest precedence, so 2**1+1 is 3, not 4, and 3*1**3 is
3, not 27.
·
Multiplication
and Division have the same precedence, which is higher than Addition and Subtraction,
which also have the same precedence. So 2*3-1 is 5, not 4, and 6+4/2 is 8, not
5.
·
Operators with
the same precedence are evaluated from left to right.
Related Topics
Privacy Policy, Terms and Conditions, DMCA Policy and Compliant
Copyright © 2018-2023 BrainKart.com; All Rights Reserved. Developed by Therithal info, Chennai.