Table of Contents
show
Program Code
# take two inputs
num1 = input('Enter first number: ')
num2 = input('Enter second number: ')
# add the inputs
sum = float(num1) + float(num2)
# display the sum
print('The sum of {0} and {1} is {2}'.format(num1, num2, sum))
Input Given:
Enter first number: 56 Enter second number: 65
Expected Output:
The sum of 56 and 65 is 121.0
Code Explanation
- We are taking two inputs from the user and storing them in the variables
num1
andnum2
. - We are converting the inputs to float and storing the result in the variable
sum
. - We are printing the sum of the two numbers.