In: Computer Science
Write functions that do the following in Python:
i) A function that takes 2 arguments and adds them. The result returned is the sum of the parameters.
ii) A function that takes 2 arguments and returns the difference,
iii) A function that calls both functions in i) and ii) and prints the product of the values returned by both.
# creating fun1, function arguments are a,b
def fun1(a,b):
## adding a and b, assigning value to c
c=a+b
return c ## returning value c
# creating fun2, function arguments are a,b
def fun2(a,b):
## for knowing bigger number comparing both a and b arguments
if a >= b:
c=a-b ## performing substratoin
else:
c=b-a ## performing substratoin
return c ## returning value c
## writing 3rd function for calls both functions in i) and
ii)
def calling():
## taking input from the user
a=int(input("Enter value of a:\t"))
b=int(input("Enter value of b:\t"))
x=fun1(a,b) ## calling fun1(a,b) and assigning return value to
x
c=int(input("Enter value of c:\t"))
d=int(input("Enter value of d:\t"))
y=fun2(c,d) ## calling fun2(c,d) and assigning return value to
y
z=x*y ## here is multiplication of results
print("product of fun1(",a,b,")", "and fun2(",c,d,")is : ",z)##
printing result
## calling function
calling()
SOLUTION SCREEN
OUTPUT Screen