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


Introduction

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

I have used python 3.7 compiler for debugging purpose.


techstudy.org

HP 15 Core i3 7th gen Laptop(4GB, 1TB HDD, Windows 10) | Rs. 31,490

  1. def sum(x, y):
  2. sum = x + y
  3. if sum in range(15, 20):
  4. return 20
  5. else:
  6. return sum
  7.  
  8. print(sum(10, 6))
  9. print(sum(10, 2))
  10. print(sum(10, 12))

Result

python language techstudy.org

     





Related Topics




Popular Posts