Certified Entry-Level Python Programmer (PCEP-30-02) Practice Exam

Session length

1 / 20

What keyword is used to define a function in Python?

function

define

def

In Python, the keyword used to define a function is "def." This keyword is essential as it indicates to the interpreter that a new function is being created. The syntax for defining a function begins with "def," followed by the function name, parentheses (which may include parameters), and a colon to indicate the start of the function body. For example:

```python

def my_function():

print("Hello, World!")

```

Here, "def" signals the start of a function definition, allowing you to encapsulate code that can be reused by calling the function by its name. The correct choice reflects the foundational knowledge of function declaration in Python, which is pivotal for writing organized and efficient code.

The other options, while sounding plausible, do not correspond to the actual syntax recognized by Python for function definitions. Thus, "def" is the only valid keyword to use in this context.

func

Next Question
Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy