What is the correct way to define a function in Python?
Correct answer
A. def function_name(parameters):
17 views
A. def function_name(parameters):
17 views
A Python function is defined with the def keyword: def function_name(parameters):, followed by an indented body. The colon and the indentation are compulsory.
The function keyword and arrow syntax belong to JavaScript, and void name() { } is C, C++ or Java style.
Want more practice? Try the full set of Computer Science MCQs on MCQsExam.com.
Not sure why the answer is A? Ask here and get an explanation.