Basic Programs

If Else Programs

While loop Programs

For loop Programs

List Programs


Python Program to Add Two Numbers With User Input


In this program, you will learn to add two numbers with user input and display the sum value using print() function.

example.py
a=float(input("Enter First Number : "))
b=float(input("Enter Second Number : "))
c=a+b
print("Sum of {} and {} is {} ".format(a,b,c))

Output

Enter First Number : 25
Enter Second Number : 36
Sum of 25 and 36 is 61

Here,

  • input() method used to get input from the user
  • float() method used to convert a string to a floating-point value.
  • format() method used to format the string with given value.

Prev Next