- To print the sum of 2 numbers
User Input: 2,3
Output: 5
print("Enter two numbers : ", end="")
n1=int(input())
n2=int(input())
print("Sum :",n1+n2)
Enter two numbers : 7 9 Sum : 16Program
Here, we use 2 variables (above code n1
& n2
) to take numbers from the user
Now, Just use the add(+) operator to print the sum of the numbers
#use add(+) operator
print("Sum :", n1+n2)
For devision (/), subtraction (-), multiplication (*), you can use their respective operators
Concept