Learn about Python Program to Add Two Numbers Provided by User in the below code example. Also, refer to the comments in the code snippet to get a detailed view about what’s actually happening.
Contents
Python Program to Add Two Numbers Provided by User
The program adds the two numbers given by the user and displays the result.
# python program to add two numbers provided by the user
num1 = input('Enter First Number: ')
num2 = input('Enter Second Number: ')
# add two numbers
# User might also enter float numbers
sum = float(num1) + float(num2)
# displaying the adding result
print('The sum of numbers {0} and {1} is {2}'.format(num1, num2, sum))
Output:
Enter First Number: 6
Enter Second Number: 7
The sum of numbers 6 and 7 is 13.0
Hope above code works for you and Refer the below Related Codes to gain more insights. Happy coding and come back again.
Similar Code : Python Program to Add (+) Two Numbers