Python: Sum of two given integers. However, if the sum is between 15 to 20 it will return 20
Python Basic: Exercise-34 with Solution
Write a Python program to sum of two given integers. However, if the sum is between 15 to 20 it will return 20.
Sample Solution:-
def sum(x, y):
sum = x + y
if sum in range(15, 20):
return 20
else:
return sum
print(sum(10, 6))
print(sum(10, 2))
print(sum(10, 12))
========== RESTART: F:/Python_APSC/py-ex-basic-34.py =============
20
12
22
>>>
沒有留言:
張貼留言