Python Programming Examples Tutorial Index

Python Number Programs

It is a basic Python program that sums two given numbers. It takes two numeric inputs from the user and performs arithmetic operations on them. Next, it assigns the output to a variable and then prints it on the screen.



Program:

#Taking user input
num1 = input('Enter First number: ')
num2 = input('Enter Second number: ')

#Adding the two variables
sum = float(num1) + float(num2)

#Print the output
print('The sum of {0} and {1} is {2}'.format(num1, num2, sum))

Program Output:

Enter First number: 3.9
Enter Second number: 4.2
The sum of 3.9 and 4.2 is 8.1


Found This Page Useful? Share It!
Get the Latest Tutorials and Updates
Join us on Telegram