Courseiva
easyMultiple Choice

XK0-006 Practice Question: A developer writes a Python script that uses the…

A developer writes a Python script that uses the `requests` library to fetch data from an API. The script works on the developer's workstation but fails on the server with an import error. What is the most likely cause?

⚠ Common exam trap

CompTIA often tests the distinction between runtime errors (e.g., network issues, bad endpoints) and import-time errors (e.g., missing modules), trapping candidates who confuse an ImportError with a connectivity or syntax problem.

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 `requests` module is not installed on the server

The `requests` library is a third-party Python package that must be installed separately via `pip` or a package manager. The script works on the developer's workstation because `requests` is present there, but fails on the server with an import error, indicating the module is missing from the server's Python environment. This is the most likely cause because an import error specifically points to a missing module, not to network or syntax issues.

Answer analysis

Option-by-option breakdown

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

  • ✓

    The `requests` module is not installed on the server

    Why this is correct

    The `requests` library is a third-party package, not part of Python's standard library, so it is absent unless separately installed. The workstation already has it, but the server's interpreter lacks it, producing the ImportError. Installing it via pip into the server's environment resolves the failure.

  • ✗

    The script uses an incorrect API endpoint

    Why it's wrong here

    An incorrect API endpoint produces an HTTP error or connection failure at runtime, not an import error, and would also fail on the workstation. Import errors indicate the requests module is missing from the server's Python environment. Endpoint mistakes are tempting because they break API calls, but they occur after imports succeed.

  • ✗

    The server lacks internet connectivity

    Why it's wrong here

    A missing module raises ModuleNotFoundError before any network call, so connectivity cannot produce an import error. Internet access is required when the script must reach an external API endpoint, but the failure here occurs at import time, not during the request.

  • ✗

    The script has a syntax error in the import statement

    Why it's wrong here

    A syntax error in the import statement would fail identically on the workstation, yet the script runs there, so the statement parses correctly. The failure is environmental: the requests package is absent from the server's Python environment. Syntax errors are a tempting cause of import failures but cannot explain workstation success.

About these practice questions

This XK0-006 question is part of Courseiva's 781-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 XK0-006 practice question is part of Courseiva's free CompTIA 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 XK0-006 exam.