14. Write a python function to generate the addition of two input value, for addition result in the range of 30 to 35, change the result to 30.
The output is:
three sets of input values:
x = (10, 15)
y = (9, 22)
z = (32, 16)
Expected Answer:
25
30
48
Sample Answer:
def add(a, b):
add = a + b
if add in range(30, 35):
return 30
else:
return add
print(add(10, 15))
print(add(9, 22))
print(add(32, 16))
More Exercises:
Python String ExercisesMore Numpy Exercises:
Numpy String ExercisesMore Pandas Exercises:
Pandas Series ExercisesMore Tutorials:
Python Installation - Linux (Ubuntu)