In: Computer Science
Create a Python file named num_sum.py that contains:
# TEXT CODE
# Defining function volume
def volume(arg1, arg2, arg3):
# return the product of three arguments
return arg1*arg2*arg3
# Defining function sum
# The symbol * is used to take variable number of arguments, by
convention, * is used with word args
def sum(*args):
# if zero arguments are passed simply return
if len(args) == 0:
return
#initialize varible res to 0, res stores sum of parameters
res = 0
# iterate through args
for arg in args:
# add arg to res, and update res
res = res + arg
# finally, return the res
return res
# driver code to check the above to functio with print function
# first call to print function with volume
print("Volume is:", volume(2, 3, 4))
# second call to print function with sum
print("Sum is:", sum(1, 2, 3, 4, 5))
#SCREENSHOTS
# CODE
# OUTPUT