0

How to write a program to take two integers as input and output their sum.

2 and 8 sample input 10 sample output

19th Jan 2022, 9:22 AM
Rhys Law
Rhys Law - avatar
4 Réponses
+ 3
x=int(input()) y=int(input()) print(x+y) ...easy
19th Jan 2022, 9:26 AM
Sancho Godinho
Sancho Godinho - avatar
+ 2
Hi Rhys Law I noted that you are working your way through Python Core, so you may wish to review the following concepts. Create a variable which will receive user input, but be recognised as an integer. num1 = int(input()) Do the same for the second input, let's call it num2 From here, we can directly print a result -> print(num1 + num2) Or, we can create another variable result = num1 + num2 Which we can print print (result) See if you can create your own code from these examples
19th Jan 2022, 9:32 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 1
Thanks for your help
19th Jan 2022, 9:26 AM
Rhys Law
Rhys Law - avatar