Write a program to take two integers as input and output their sum. Sample Input: 2 8 Sample Output: 10 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Write a program to take two integers as input and output their sum. Sample Input: 2 8 Sample Output: 10

Answer please

9th Jan 2021, 5:09 PM
ツ P R I N C E└∵┐NA I Nツ
ツ P R I N C E└∵┐NA I Nツ - avatar
10 Answers
+ 8
Hmm, i don't think that using "double"-input is a clear and pythonic solution. (imaging what to do with 3, 4, 5, .. inputs?) it could be done in a sinple for loop using a range to limit count of input, or as a list comprehension: inp_lst = [] for _ in range(2): inp_lst.append(int(input())) # to see all the inputted values print(inp_lst) # to get the sum: print(sum(inp_lst)) # or: print(sum([int(inp) for _ in range(2) for inp in input() ]))
10th Jan 2021, 1:21 PM
Lothar
Lothar - avatar
+ 8
ᶜᴿᴬᶻᵞ ✿ Ꮲʀɪɴᴄᴇㅤ Nice implementation! and btw for getting the input n = [int(input()), int(input())] print(sum(n)) Although I think this is a little slower (when program gets larger) because in the background, the program is iterating and incrementing at the same time. But it doesn't matter though with small programs.
10th Jan 2021, 9:41 AM
noteve
noteve - avatar
+ 6
Please show us your attempt so far so we may help. Hint: To take integer input: x = int(input()) y = int(input()) The first integer is assigned to x, the second integer is assigned to y. Note that in challenges, another line means another input variable. The code is up to you. And please review your lessons and read comment sections, people give some explanations and examples there. Thanks. https://www.sololearn.com/learning/4434/
9th Jan 2021, 5:15 PM
noteve
noteve - avatar
+ 4
Ok I understand
10th Jan 2021, 9:42 AM
ツ P R I N C E└∵┐NA I Nツ
ツ P R I N C E└∵┐NA I Nツ - avatar
+ 3
x = int(input()) y = int(input()) print(x+y)
11th Jan 2021, 9:43 AM
Motuncoded
Motuncoded - avatar
+ 3
# This program adds two numbers num1 = int(input()) num2 = int(input()) # Add two numbers sum = num1 + num2 # Display the sum print(sum)
24th Apr 2022, 3:33 PM
Prakhar Bansal
+ 2
n=[6,3] print(sum(n))
10th Jan 2021, 9:36 AM
ツ P R I N C E└∵┐NA I Nツ
ツ P R I N C E└∵┐NA I Nツ - avatar
+ 2
none of these answers has worked im still confused and i still keep getting the answer wrong.
21st Apr 2022, 12:41 PM
Leyani Lenard
0
x = int(input()) y = int(input()) sum = x +y print(sum)
3rd Feb 2022, 12:48 PM
Hamisu Yusuf
Hamisu  Yusuf - avatar
0
#testcase02 a=11 b=22 sum=(a+b) print(sum)
5th Jan 2023, 1:37 PM
mseay
mseay - avatar