Arithmetic operators:
Arithmetic operators perform basic arithmetic operations, for example, Addition, subtraction, multiplication, division, % modulus, exponent, etc.
Example:
For arithmetic operators, we will take a simple example of addition where we will add two-digit 4+5=9
Example:
For arithmetic operators, we will take a simple example of addition where we will add two-digit 4+5=9
Operator
|
Meaning
|
Example
|
Output
|
+
|
Addition
|
a=2+3
|
print(a): 5
|
-
|
Subtraction
|
a=4-2
|
print(a): 2
|
*
|
Multiplication
|
a=2*3
|
6
|
/
|
Division: divides left
operand by the right operand
|
a=4/2
|
2
|
%
|
Modulus gives a remainder of
division
|
4%2
|
0
|
//
|
Integer division. Floor
division. Performs division and gives only integer quotient.
|
5//2
|
2
|
**
|
Exponent operator
|
10**2
|
100
|
Priorities of Arithmetic operators:
First priority: *,/,% and floor division are equal priorities.
2nd priority: +,-
Example:
a=2+3*2
-->Here the first '*' operator is evaluated i.e: 3*2 is evaluated i.e: a=2+6-->Now '+' operator is evaluated i.e a=8
--->Now '=' assignment operator is evaluated i.e 8 is stored in variable 'a'
Youtube channel Related video
Next topic: Example
programs on Arithmetic OperatorsPrevious topic: Operators
ReplyDeleteThank you for sharing wonderful information with us to get some idea about it.
Python Online Training in Hyderabad
Python Training in Hyderabad
Python Training
Python Online Training