1. Home
  2. Data Science
  3. Python
  4. Which of the following is a valid way to define a function…

Added 5 Feb 2024

Which of the following is a valid way to define a function in Python?

  1. def function_name:
  2. function function_name():
  3. define function_name():
  4. def function_name(): Correct answer

Correct answer

D. def function_name():

19 views

MCQSEXAM

Explanation

In Python, a function is defined using the 'def' keyword, followed by the function name and parentheses. The correct syntax is shown in option 'd'.

Doubts & discussion

Not sure why the answer is D? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More Python MCQs

Practise all Python MCQs

Similar MCQs