4.2-4.6 QA Computer jr2
4.2-4.6 QA Computer jr2
Question Answers
Purpose: Used for comparison. It checks whether two values are equal.
Example: if x == 5: # Compares whether x is equal to 5 print("x is 5")
7. Why is it harder for a programmer to spot a logical error than a syntax error?
Syntax errors are easier to identify because the Python interpreter highlights them
immediately when you run the program, indicating where the issue is.
Logical errors, on the other hand, occur when the program runs without errors but produces
incorrect or unintended results. These errors require the programmer to manually debug and
trace the logic to identify what went wrong.
8. Write a Python program that adds together five numbers input by the user.
total = 0
for i in range(5):
total += number
output
Enter a number: 1
Enter a number: 3
Enter a number: 2
Enter a number: 6
Enter a number: 7