Courseiva
Modules and PackageseasyMultiple ChoiceObjective-mapped

PCAP Modules and Packages Practice Question

Which of the following is a valid way to import a module named 'math' and assign it an alias 'm'?

⚠ Common exam trap

Python Institute often tests the misconception that `alias` is a Python keyword or that `from ... import *` can be combined with `as`, leading candidates to pick options A or B instead of the correct `import ... as ...` syntax.

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

import math as m

Python's `import` statement allows you to import a module and assign it an alias using the `as` keyword, as in `import math as m`. This creates a reference to the `math` module under the name `m`, so you can call functions like `m.sqrt(16)` without polluting the namespace with the original module name.

Answer analysis

Option-by-option breakdown

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

  • alias math as m

    Why it's wrong here

    The statement `alias math as m` is invalid because `alias` is not a Python keyword; there is no built-in statement or function that begins with `alias`. The correct keyword for binding a module to a new local name is `import`, and the `as` clause is part of the import statement syntax (e.g., `import math as m`). Even if a variable named `alias` existed, calling it would not trigger an import—it would just be an attribute access or function call, not a module import operation.

  • from math import * as m

    Why it's wrong here

    The syntax `from math import * as m` is invalid because the `as` clause cannot be combined with a star import. In Python, `from math import *` is a complete statement that imports every public name from the module into the current namespace, but it does not produce a single object that could be assigned to an alias. The grammar of the import statement simply does not permit `as` after `*`; it only allows `as` after an explicitly named module or attribute, such as `from math import sqrt as s`.

  • import m from math

    Why it's wrong here

    The line `import m from math` is syntactically incorrect because the `import` statement does not place the `from` clause after the imported name. The correct ordering is either `import math` or `from math import m`. Furthermore, even if you wrote `from math import m`, that would import the attribute `m` (if it existed) from the `math` module, not alias the entire `math` module—so it would not achieve the goal of binding the module itself to the name `m`.

  • import math as m

    Why this is correct

    `import math as m` is the correct and idiomatic way to import the `math` module while binding it to the local name `m`. The `as` clause in an import statement creates an alias for the module object, so every subsequent reference to `m` (such as `m.sqrt(2)`) accesses the `math` module's functionality without needing to type the full module name. This is a standard feature of the import system, commonly used to shorten long module names or avoid name conflicts.

About these practice questions

Courseiva writes every PCAP question from scratch — 169 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or 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 PCAP 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 PCAP exam.