Addition of two numbers using python
In this program, the input function prompts the user to enter two numbers, which are then converted to float data types and stored in num1 and num2 variables, respectively. The two numbers are added together and stored in the sum variable. Finally, the result is displayed to the user using the print function, using the format method to substitute the values of num1, num2, and sum into a formatted string .
Input :
num1 = float(input("Enter first number: "))
num2 = float(input("Enter second number: "))
# Add two numbers
sum = num1 + num2
# Display the sum
print('The sum of {0} and {1} is {2}'.format(num1, num2, sum))
Output :
Enter first number: 83
Enter second number: 44
The sum of 83.0 and 44.0 is 127.0