Tech Study

Write a Python program to add two objects if both objects are an integer type

Introduction

Write a Python program to add two objects if both objects are an integer type. I have used python 3.7 compiler for debugging purpose.

def add_numbers(x, y):
    if not (isinstance(x, int) and isinstance(y, int)):
         raise TypeError("Inputs must be integers")
    return x + y
 
print(add_numbers(30, 20))

Result

Write a Python program to add two objects if both objects are an integer type
Write a Python program to add two objects if both objects are an integer type

TaggedWrite a Python program to add two objects if both objects are an integer type

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