-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathex21.py
More file actions
36 lines (24 loc) · 872 Bytes
/
ex21.py
File metadata and controls
36 lines (24 loc) · 872 Bytes
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
def add(a, b):
print "ADDING %d + %d" % (a, b)
return a + b
def subtract(a, b):
print "SUBTRACTING %d - %d" % (a, b)
return a - b
def multiply(a, b):
print "MULTIPLYING %d * %d" % (a, b)
return a * b
def divide(a, b):
print "DIVIDING %d / %d" % (a, b)
return a / b
print "Basic Mathematical Calculations through some functions with return values"
num1 = int(raw_input("Enter num1 : "))
num2 = int(raw_input("Enter num2 : "))
p = add(num1, num2)
q = subtract(num1, num2)
r = multiply(num1, num2)
s = divide(num1, num2)
print "p: %d, q: %d, r: %d, s: %d" % (p, q, r, s)
# Now Let's do something really cool......
print "Combining all the Functions....Passing the return value of one function as argument to other"
cool = add(p, subtract(q, multiply(r, divide(s, 2))))
print "That becomes: ", cool, ". Now, that's cool. Isn't it?"