► Python program to add two decimal or float numbers
Steps followed:
1. take value for two float numbers from user and store in var num1 and num2 respectively
2. convert num1 and num2 in float format to perform addition operation
3. add num1 and num2 and store value in "add" variable
4. print result
#python program to add two decimal or float numbers
#getting value for two float numbers from user and storing in var num1 and num2 respectively
num1=input("enter value for first number: ")
num2=input("enter value for second number: ")
#python always stores user input in string format
#converting num1 and num2 in float format
num1=float(num1)
num2=float(num2)
#adding num1 and num2 and storing value in "add" variable
add = num1+num2
#printing result
print("%0.2f + %0.2f = %0.2f"%(num1,num2,add))
enter value for first number: 20.6
enter value for second number: 29.4
20.60 + 29.40 = 50.00