For this kind of problems you have to design a program. The program is then tested against test cases, i.e. sample inputs and outputs. When the program is run with a particular sample input it has to produce the sample output. If the output is different the test will fail. Even a small difference such as an extra blank space or a missing character will make the test to fail.
For this particular problem we have to write a program that reads two integer numbers, a and b, and print their sum, a + b.
The following code is an attempt to solve the problem:
# Reads a
a = int(input("Write a:"))
# Reads b
b = int(input("Write b:"))
Prints the sum
print(a + b)
Copy it to the program area and hit COMPILE & TEST.
The result is a Compilation Error. The details of the error are at the end in the Compilation Log text box. The reason is that we forgot to put the comment sign (#) at the beginning of line 5. The program with the fixed syntax error is the following:
# Reads a
a = int(input("Write a:"))
# Reads b
b = int(input("Write b:"))
# Prints the sum
print(a + b)
Copy it again to the program area and hit COMPILE & TEST.
Now we get a Wrong Answer result. It means that the program runs but it does not produce the expected answer. The reason is that inside the input()
command with are putting the string "Write a:"
and "Write b:"
and this is written to the output along with the result. This is useful for a program that interacts with a user, but in this case we will avoid to put messages inside input()
.
The fixed code is the following:
# Reads a
a = int(input())
# Reads b
b = int(input())
# Prints the sum
print(a + b)
Now you can COMPILE & TEST it. If it works we can proceed to submit the final answer to the problem hitting the button Submit.