Courseiva
Modules and Packages →easyMultiple Choice

PCAP Modules and Packages Practice Question

A script contains the following lines:

import math
from math import sqrt

print(math.sqrt(16))
print(sqrt(25))

What is the output when the script is executed?

⚠ Common exam trap

The trap here is thinking that importing a module and a function from that module causes a conflict or that sqrt returns an integer.

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

✓

4.0 and 5.0

The script imports the math module and also imports the sqrt function directly. Both math.sqrt and sqrt are available. Calling math.sqrt(16) returns 4.0, and calling sqrt(25) returns 5.0. The output is two lines: 4.0 and 5.0. The other options misstate the return type, claim an error due to double import, or incorrectly assume sqrt becomes undefined.

Answer analysis

Option-by-option breakdown

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

  • ✓

    4.0 and 5.0

    Why this is correct

    The script imports the math module and also imports the sqrt function directly into the global namespace. The first print uses math.sqrt(16), which returns 4.0. The second print uses the directly imported sqrt(25), which returns 5.0. Both calls are valid, and the output is 4.0 followed by 5.0 on separate lines. There is no conflict because the names math and sqrt refer to different objects.

  • ✗

    An error occurs because sqrt is imported twice, causing a name clash.

    Why it's wrong here

    Importing math and then from math import sqrt does not cause a clash. The name math refers to the module, and sqrt refers to the function. They are distinct names in the global namespace. Python allows both forms of import simultaneously. There is no error; the script runs and prints the square roots. This option misunderstands how names are bound during imports.

  • ✗

    4 and 5

    Why it's wrong here

    The math.sqrt function always returns a float, even for perfect squares. So math.sqrt(16) yields 4.0, not the integer 4. Similarly, sqrt(25) yields 5.0. The output would not be integers. This option ignores the return type of the sqrt function, which is float. The correct output includes decimal points.

  • ✗

    4.0 and an error, because sqrt is not defined after importing math.

    Why it's wrong here

    The statement from math import sqrt explicitly binds the name sqrt to the function in the global namespace. Therefore, sqrt is defined and can be called. The import math statement does not remove or undefine sqrt. Both names coexist. The second print will succeed and output 5.0. This option incorrectly assumes that importing the module somehow invalidates the direct import.

About these practice questions

Courseiva writes every PCAP question from scratch — 421 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 and reviewed by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

Last reviewed September 2026 · checked against the official Python Institute exam blueprint

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.