-
Notifications
You must be signed in to change notification settings - Fork 0
/
pyMath.py
50 lines (40 loc) · 792 Bytes
/
pyMath.py
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
#!/usr/bin/python
a = 21
b = 10
c = 0
#addition
c = a + b
print "Line 1 - Value of c is ", c
#Addition Shortcut. Same as c=c+a
c += a
print "Line 2 - Value of c is ", c
#Subtraction
c = a - b
print "Line 2 - Value of c is ", c
c -= a #same as saying c=c-a
print "Line 2 - Value of c is ", c
#Multiplication
c= a * b
c *= a
print "Line 3 - Value of c is ", c
#Division
c = b / a
c /= a
print "Line 4 - Value of c is ", c
#Modulus Division
#It takes modulus using two operands and assign the result to left operand
c = b % a
c %= a
print "Line 5 - Value of c is ", c
a = 2
b = 3
#Exponential Power
c = a ** b #Equivalent to c=a^b
c **= a #Equivalent to c=c^b
print "Line 6 - Value of c is ", c
#Floor Division
a = 10
b = 5
c = a//b
c //= a
print "Line 7 - Value of c is ", c