Which TWO of the following code snippets will result in a SyntaxError? (Choose two.)
Trap 1: a = 1; b = 2
Valid syntax: multiple statements separated by semicolons are allowed on one line.
Trap 2: print('hello')
Valid syntax: `print('hello')` is a correct function call in Python 3.
Trap 3: for i in range(5): print(i)
Valid syntax: the `for` loop has a colon and proper indentation.
- A
a = 1; b = 2
Why wrong: Valid syntax: multiple statements separated by semicolons are allowed on one line.
- B
print('hello')
Why wrong: Valid syntax: `print('hello')` is a correct function call in Python 3.
- C
for i in range(5): print(i)
Why wrong: Valid syntax: the `for` loop has a colon and proper indentation.
- D
if x > 5 print('big')
SyntaxError: the `if` statement is missing a colon after the condition.
- E
if x > 5: print('big')
Why wrong: Valid syntax: the `if` statement has a colon and proper indentation.