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
1 2 3 4 5 6 |
a = int(input("enter first number: ")) b = int(input("enter second number: ")) sum = a + b print("sum:", sum) |
Output
enter first number:5
enter second number:7
sum: 12
Video Tutorial
Need Python Programming Help? Visit AssignmentXp.com, 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.
Hi, please give detailed explanation
YEAH PLEASE GIVE IN DETAIL
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
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
Hi
I am also a computer science student.
Help me learn Python?
Thank you
You should learn Python first ,it is very easy to learn. You can learn it from youtube
use solo learn app
If you want be a programmer don’t depend on anyone. Do practice of your own self study is the main thing for programmers
Rewards
Nayaz
ur code gives a runtime error
Thanks so much, Neeraj! I really appreciate you helping out us fellow programmers with our coding, even though you don’t have to! 🙂
We need
Nested For Loops
Nested While Loop
Function (1)
Nested if
If else if
Class
Just an examples with minimun 15 lines of codes
Thanks for the assist. It helped me in my Codecademy lessons
Thank you developer of this site. This helped me a lot. Now I don’t have any problem in programming anymore. 👍🏻👍🏻👍🏻
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:
num1=1
num2=1
result=num1+num2
print(result)
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
print(Sum(1,1))
NameError: name ‘Sum’ is not defined
Please assist on how I can fix this error.
@Hilda coombe
you have not defined Sum anywhere. for ur given question u can try the following ways. (I am a beginner too)
a=4
b=5
def Sum(a,b):
print(a+b)
Sum(a,b)
#OR Other Way
a=int(input(“please enter 1st value :”))
b=int(input(“please enter 12nd value :”))
def Sum(a,b):
print(a+b)
Sum(a,b)