Question:

Write down the syntax for defining a function in Python.

Show Hint

Always remember: Python functions require a colon (:) and indentation to define the block of code.
Updated On: Mar 14, 2026
Hide Solution
collegedunia
Verified By Collegedunia

Solution and Explanation

Step 1: Understand function definition in Python.
In Python, functions are defined using the keyword \texttt{def}. This keyword tells the interpreter that a function is being declared.
Step 2: Structure of function definition.
The basic syntax for defining a function includes: • The keyword \texttt{def}
• The function name
• Parentheses containing parameters
• A colon at the end
• An indented block of statements
Step 3: Example.
\[ \texttt{def greet():} \] \[ \texttt{\ \ print("Hello")} \] When this function is called, it prints the message Hello.
Step 4: Conclusion.
Therefore the syntax for defining a function in Python begins with the keyword \texttt{def} followed by the function name and parameters.
Was this answer helpful?
0
0