forked from remon/pythonCodes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArithemtic_operators_en.py
More file actions
59 lines (50 loc) · 1.93 KB
/
Copy pathArithemtic_operators_en.py
File metadata and controls
59 lines (50 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# Examples on how to uses Python Arithmetic Operators
'''
What is the operator in Python?
Operators are special symbols in Python that carry out arithmetic or logical computation.
The value that the operator operates on is called the operand.
for example: 2 + 3 = 5
Here, + is the operator that performs addition.
2 and 3 are the operands and 5 is the output of the operation.
what is Arithmetic Operators means ?
Operator | Description
-----------------------------------------------
+ Addition | Adds values on either side of the operator.
- Subtraction | Subtracts right hand operand from left hand operand.
* Multiplication | Multiplies values on either side of the operator
/ Division | Divides left hand operand by right hand operand
% Modulus | Divides left hand operand by right hand operand and returns remainder
** Exponent | Performs exponential (power) calculation on operators
// Floor Division | he division of operands where the result is the quotient in which the digits after the decimal point are removed. But if one of the operands is negative, the result is floored, i.e., rounded away from zero
when do we use it ?
we use this kind of every where form basic math operation to loops or condition statements
'''
a = 20 ; b = 10
# Addition operator
c = a + b
print "Addition value =" , c
# Subtraction operator
c = a - b
print "Subtraction value = " , c
# Multipliction operator
c = a * b
print "Multipliction value = " , c
# Division operator
c = a / b
print "Division value = " , c
# Mod operator
c = a % b
print "Mod value = " , c
# Exponent or power operator
a = 2 ; b = 3
c = a ** b
print "Exponent value = " , c
# floor Division or integer division operator
'''
Note :
In Python 3 the division of 5 / 2 will return 2.5 this is floating point division
the floor Division or integer divisio will return 2 mean return only the integer value
'''
a = 9 ; b = 4
c = a // b
print "Integer Division value = " , c