Courseiva

PCEP Computer Programming and Python Fundamentals Practice Question

Which TWO statements correctly describe Python's dynamic typing?

⚠ Common exam trap

The PCEP exam often tests the misconception that dynamic typing means a variable's type is fixed after first assignment, or that type checking happens at compile time, leading candidates to incorrectly select Option C or B.

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

✓

The interpreter infers the type from the assigned value.

Option D is correct because Python is dynamically typed: when you write an assignment such as x = 42, the interpreter determines the type of the object (int) from the value on the right-hand side at runtime, without any explicit type declaration. Option E is correct because a name in Python is just a reference to an object, so the same variable can be rebound to an object of a different type later, e.g., x = 42 followed by x = 'hello' changes x from int to str at runtime. Option A is wrong because Python requires no type declarations; types are attached to objects, not to variable names. Option B is wrong because Python performs type checking at runtime, not at compile time (the CPython compiler only produces bytecode and does not enforce types). Option C is wrong because a variable's type is not fixed after assignment; rebinding the name to a new object of another type is perfectly legal.

Answer analysis

Option-by-option breakdown

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

  • ✗

    Variable types must be declared before use.

    Why it's wrong here

    Python requires no type declarations; assigning a value creates the binding and infers the type from the object itself. This option appeals to programmers from languages like C or Java, where declaring a variable's type before use is mandatory and enforced by the compiler.

  • ✗

    Python checks types only at compile time.

    Why it's wrong here

    Python binds types to objects at runtime, not at compile time; the interpreter executes bytecode without static type checking. This option is tempting because compiled languages such as C or Java do check declared types during compilation, which is the correct model there but not in Python.

  • ✗

    A variable's type is fixed once assigned.

    Why it's wrong here

    A name in Python is merely a reference that can be rebound to an object of any type at any moment, so its type is not fixed. This tempts candidates who conflate variables with statically typed declarations, where a variable's type is indeed locked after assignment.

  • ✓

    The interpreter infers the type from the assigned value.

    Why this is correct

    Python determines a variable's type at assignment time from the object bound to it, with no type declaration required. The interpreter infers the type from the assigned value, which is the mechanism underlying dynamic typing rather than static annotation.

  • ✓

    The type of a variable can change at runtime.

    Why this is correct

    Because names bind to objects rather than fixed types, rebinding a variable to a value of another type is permitted; the same name can hold an integer then a string. This runtime mutability of type is a defining consequence of Python's dynamic typing model.

About these practice questions

This PCEP question is part of Courseiva's 482-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. 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.