w3resource
Python Exercises

Python: Compute and print sum of two given integers

Python Basic - 1: Exercise-41 with Solution

Write a Python program to compute and print sum of two given integers (more than or equal to zero). If given integers or the sum have more than 80 digits, print "overflow".

Sample Solution:

Python Code:

print("Input first integer:")
x = int(input())
print("Input second integer:")
y = int(input())
if x >= 10 ** 80 or y >= 10 ** 80 or x + y >= 10 ** 80:
    print("Overflow!")
else:
    print("Sum of the two integers: ",x + y)

Sample Output:

Input first integer:
 25
Input second integer:
 22
Sum of the two integers:  47

Flowchart:

Flowchart: Python - Compute and print sum of two given integers

Python Code Editor:

Have another way to solve this solution? Contribute your code (and comments) through Disqus.

Previous: Write a Python program to check if a point (x,y) is in a triangle or not. There is a triangle formed by three points.
Next: Write a Python program that accepts six numbers as input and sorts them in descending order.

What is the difficulty level of this exercise?