499,401 views
43 votes
43 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?

User BenMQ
by
2.4k points

1 Answer

18 votes
18 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)

User Piotr Lesnicki
by
3.0k points