Python Program to Add Two Numbers [With Example]

Here you will get python program to add two numbers.

The program will first ask user to enter two numbers, calculate their sum and finally print it.

input() is an inbuilt function which is used to take input from user.

Python Program to Add Two Numbers


enter first number:5
enter second number:7
sum: 12

Video Tutorial

Need Python Programming Help? Visit, they have expert python programmers available 24*7.

Python programming is an essential skill for many computer science fields

However, it can be challenging to learn and complete programming assignments on your own. That’s why Python assignment help is available to make programming easier and less stressful. With the right guidance, you can quickly become proficient in coding with Python and complete programming assignments without much effort. Professional programming experts can provide the help and support you need to tackle even the most complex programming assignments. They can answer any programming questions you have, explain programming concepts in detail, and provide advice and suggestions on how best to approach programming challenges. With their expertise, you’ll be able to write effective Python code with ease and confidence.

15 thoughts on “Python Program to Add Two Numbers [With Example]”

  1. Hiii am Arun student of Computer science means programmer plz help me am now biginner programmer but I take intereste in Programming world .But I don’t have any Senior and Coach .
    Can you help me

    1. Sure if you are going with programming you need to start from somewhere and i believe since you are cse students so you must be knowing oop so better is to start with java core and after that you will get an idea how and where to go. Perhaps with python ruby big data java script or anything you like

  2. Thanks so much, Neeraj! I really appreciate you helping out us fellow programmers with our coding, even though you don’t have to! 🙂

  3. We need
    Nested For Loops
    Nested While Loop
    Function (1)
    Nested if
    If else if

    Just an examples with minimun 15 lines of codes

  4. Thank you developer of this site. This helped me a lot. Now I don’t have any problem in programming anymore. 👍🏻👍🏻👍🏻

  5. Good day, I am learning Python programming, I have been asked to”
    Write a Python function Sum() to add two numbers
    For example:
    Test Result
    print(Sum(1,1)) 2
    print(Sum(1,2)) 3
    print(Sum(1,3)) 4

    This is the code which I wrote:

    However, when I try to submit my results, I get the following answer:
    ***Run error***
    Traceback (most recent call last):
    File “__tester__.python3”, line 13, in
    NameError: name ‘Sum’ is not defined

    Please assist on how I can fix this error.

  6. @Hilda coombe
    you have not defined Sum anywhere. for ur given question u can try the following ways. (I am a beginner too)

    def Sum(a,b):

    #OR Other Way

    a=int(input(“please enter 1st value :”))
    b=int(input(“please enter 12nd value :”))
    def Sum(a,b):

Leave a Comment

Your email address will not be published. Required fields are marked *