Courseiva

PCEP Computer Programming and Python Fundamentals Practice Question

Which keyword is used to define a function in Python?

⚠ Common exam trap

The PCEP exam often tests that candidates know `def` is the only correct keyword, while distractors like `function` (used in JavaScript) or `define` (a generic term) exploit confusion with other programming languages or natural language.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

def

In Python, the `def` keyword is used to define a function, followed by the function name, parentheses, and a colon. This is a fundamental syntax rule in the Python language specification, and no other keyword or identifier is valid for this purpose.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✓

    def

    Why this is correct

    The `def` keyword introduces a function definition, binding the function name to a callable object at runtime. It satisfies the stem's requirement for the specific keyword that declares functions, unlike `lambda` (anonymous expressions) or `class` (type definitions). Every named function in Python begins with `def`, followed by the name and parameter list.

  • ✗

    func

    Why it's wrong here

    'func' is not a reserved Python keyword; it is a common identifier in languages like Go and Swift. Python declares functions with 'def', so 'func' is parsed as an ordinary name and the statement fails with a SyntaxError.

  • ✗

    function

    Why it's wrong here

    Python reserves no 'function' keyword; functions are declared with 'def'. The word appears in many other languages, which makes it tempting, but Python's grammar defines functions solely through 'def', so 'function' raises a SyntaxError at parse time.

  • ✗

    define

    Why it's wrong here

    'define' is not a Python keyword; it belongs to languages such as C and PHP for constants and functions. Python instead uses 'def' to declare functions, so writing 'define' produces a SyntaxError rather than a function definition.

About these practice questions

One of 482 original PCEP practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This PCEP practice question is part of Courseiva's free Python Institute certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the PCEP exam.