Tech Study

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.

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))

Result

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

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

Java Final keyword

Introduction : java final keyword The final keyword present in Java programming language is generally used for restricting the user. …

Read more

C++ Memory Management: new and delete

C++ Memory Management We know that arrays store contiguous and the same type of memory blocks, so memory is allocated …

Read more