Question:

Which keyword is used to define a function in Python?

Show Hint

Python uses very concise keywords. For defining functions, always use def, and remember that Python function definitions must be followed by a colon and indentation.
Updated On: Jun 3, 2026
  • function
  • define
  • def
  • fun
Show Solution
collegedunia
Verified By Collegedunia

The Correct Option is C

Solution and Explanation


Step 1: Understanding the Question:

This question asks for the specific reserved word (keyword) used in Python syntax to declare and define a user-defined function.

Step 2: Detailed Explanation:

$\bullet$ In Python, functions are defined using the reserved keyword def.
$\bullet$ The general syntax of a function definition in Python is as follows:
$\bullet$ def function_name(parameters): followed by an indented block of code representing the function body.
$\bullet$ Let us evaluate the alternative options:
$\bullet$ Option (A) function is used in languages like JavaScript, PHP, and Swift to define functions, but it is not a keyword in Python.
$\bullet$ Option (B) define is used in some macro systems (like C/C++ preprocessors via #define) but is not a valid Python keyword for functions.
$\bullet$ Option (D) fun is used in languages such as Kotlin and Rust (which uses fn) but is incorrect in the context of Python.
$\bullet$ The def keyword stands for "define" and is a core part of Python's simple and readable syntax.

Step 3: Final Answer:

Therefore, the correct keyword to define a function in Python is def, which corresponds to option (C).
Was this answer helpful?
0
0