Help on how to create a simple calculator | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 1

Help on how to create a simple calculator

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

30th Nov 2022, 7:43 AM
Unzima Patrickson
Unzima Patrickson - avatar
8 Answers
+ 6
Anonymous , i suppose this question is relared to ths *python core* tutorial. (exercise17) all coding for code coach exercises can not have any user prompt inside the input() function. if this is not taken into account, the code will not pass the test cases. also all additional output that is not requested will create errors when running the code.
30th Nov 2022, 5:04 PM
Lothar
Lothar - avatar
+ 4
https://code.sololearn.com/cfao0DfmqtTq/?ref=app Patrickson Unzima Your code just get one number and it is printed... Print Statement should be like this print (num)... Go through python beginners course for better understanding..
30th Nov 2022, 8:07 AM
Riya
Riya - avatar
+ 2
Post your tried code..
30th Nov 2022, 7:46 AM
Riya
Riya - avatar
+ 2
Anonymous that's hard coded and not what the question asks, you need to take two inputs.
30th Nov 2022, 10:05 AM
Ausgrindtube
Ausgrindtube - avatar
+ 1
Ausgrindtube if we have to take input and enter the data by user, then code will be:- a = int(input("Enter the number 1:") b = int(input("Enter the number 2:") print ("The addition is:", a+b)
30th Nov 2022, 10:10 AM
Anonymous
Anonymous - avatar
0
num = int(input ()) Print "num"
30th Nov 2022, 7:48 AM
Unzima Patrickson
Unzima Patrickson - avatar
0
Make two vars with input and put them together
30th Nov 2022, 9:33 PM
Steven Sypien
Steven Sypien - avatar
- 2
a = 2 b = 8 print (a+b)
30th Nov 2022, 8:13 AM
Anonymous
Anonymous - avatar