Python Program to Add Two Numbers

    Program Code

    # take two inputs
    num1 = input('Enter first number: ')
    num2 = input('Enter second number: ')
    # add the inputs
    sum = float(num1) + float(num2)
    # display the sum
    print('The sum of {0} and {1} is {2}'.format(num1, num2, sum))

    Input Given:

    Enter first number: 56
    Enter second number: 65

    Expected Output:

    The sum of 56 and 65 is 121.0

    Code Explanation

    1. We are taking two inputs from the user and storing them in the variables num1 and num2.
    2. We are converting the inputs to float and storing the result in the variable sum.
    3. We are printing the sum of the two numbers.
    Disclaimer: While we make every effort to update the information, products, and services on our website and related platforms/websites, inadvertent inaccuracies, typographical errors, or delays in updating the information may occur. The material provided on this site and associated web pages is for reference and general information purposes only. In case of any inconsistencies between the information provided on this site and the respective product/service document, the details mentioned in the product/service document shall prevail. Subscribers and users are advised to seek professional advice before acting on the information contained herein. It is recommended that users make an informed decision regarding any product or service after reviewing the relevant product/service document and applicable terms and conditions. If any inconsistencies are observed, please reach out to us.

    Latest Articles

    Related Stories

    Leave A Reply

    Please enter your comment!
    Please enter your name here

    Join our newsletter and stay updated!