+ 3
Write a program to take two integers as input and output their sum. Sample Input: 2 8 Sample Output: 10
Answer please
10 Respostas
+ 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() ]))
+ 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.
+ 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/
+ 4
Ok I understand
+ 3
x = int(input())
y = int(input())
print(x+y)
+ 3
# This program adds two numbers
num1 = int(input())
num2 = int(input())
# Add two numbers
sum = num1 + num2
# Display the sum
print(sum)
+ 2
n=[6,3]
print(sum(n))
+ 2
none of these answers has worked im still confused and i still keep getting the answer wrong.
0
x = int(input())
y = int(input())
sum = x +y
print(sum)
0
#testcase02
a=11
b=22
sum=(a+b)
print(sum)