Write the function sum() with four parameters the calculates the arguments provided and returns their sum
Parameters four variables of type float
Returns the sum of type float
Use the default argument 4 to declare the last two parameter of the function sum() test the function sum() by calling it by three possible methods use random integers as arguments
def sum(a1, a2, a3 = 4, a4 = 4):
return a1+a2+a3+a4
print(sum(1.5, 2, 3.5))
print(sum(7, 0.2))
print(sum(1.5, 2, 3.5 , 6.8))
Comments
Leave a comment