Syntax in Python MCQs Exercise II

Ques 1 Syntax


What is the purpose of the pass statement in Python?

A To define a function with no body
B To exit a loop immediately
C To skip a block of code
D To raise an exception

Ques 2 Syntax


What is the output of the following code?

def test(a, b=[]):
    b.append(a)
    return b
print(test(1))
print(test(2))

A [1], [2]
B [1], [1, 2]
C [1], [2]
D RuntimeError

Ques 3 Syntax


Which of the following is not a valid Syntax in Python?

A x = 10 if 5 > 3 else 20
B x = lambda x: x**2
C x = [y for y in range(5) if y%2 == 0]
D x = match 10 case 10: 20