Write a Python program to sum two given integers. However, if the sum is between 15 and 20 it will return 20.

Write a Python program to sum two given integers. However, if the sum is between 15 and 20 it will return 20.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
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))

Final output

Leave a Comment