2
QuizMultiple Choice

Resources for Programmers — Unit test

Question 2 • Introduction to Information Technology - EL3701

A Python programmer is writing a function definition. What syntax should be used?

Answer
A
def( statement ): functionName argument1 argument2 argument3
B
def functionName( arguments ): statement1 statement2 statement3
C
def functionName( statement ): argument1 argument2 argument3
D
def( arguments ): functionName statement1 statement2 statement3

Explanation

A Python function definition starts with the keyword `def`, followed by the function name and parentheses containing any arguments. A colon then introduces the function body, which contains the statements to run. Therefore, the correct syntax is `def functionName(arguments): statement1 statement2 statement3`, choice B.

AI-written and checked against the verified answer.

Previous
Next