Online visitors

People learning around the world

Online

—

Visitors exploring W3Schools

Online visitors by country Circles show approximate country locations. The country list provides the visitor counts.

Circles represent countries, not exact visitor locations.

Country

Online

Loading country activity…

    Python Program to Add Two Given Numbers

    Python Programming Examples


    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

    Notifications

    Updates are enabled for this browser.

    Receive new tutorials, articles and learning resources. You can turn updates off anytime.