175k views
5 votes
You are creating a function that will test whether a number is greater than 10 using these lines of code:

if a < 10:
print(a "is greater than 10")

can you identify one syntax error and one logic error in these lines? why do you think a programmer might have made the logic error?

1 Answer

6 votes

Answer:

There is no indentation on the second line - Python needs indentation for if statements to work

The if statement is incorrect - We want the if statement to check if a is greater than 10 not less than 10

A programmer might have made this error by confusing the less than and greater than signs

(I'm assuming this is python)