• ¿Documento equivocado? Cámbialo gratis
  • Escrito por estudiantes que aprobaron
  • Inmediatamente disponible después del pago
  • Leer en línea o como PDF
Vender
¿Dónde estudias?
Tu idioma
Document preview thumbnail
Vista previa 4 fuera de 107 páginas
Examen

PCAP-31-03 Practice Test: 250 Exam Questions for Python Certification

Document preview thumbnail
Vista previa 4 fuera de 107 páginas

This practice test is meticulously organized into focused modules to optimize your study time. You will master the math module for advanced calculations, the random module for generating pseudo-random numbers, and the platform module for system identification. Deep dives into the sys and os modules will solidify your understanding of Python's interaction with the operating system, file paths, and environment variables. Beyond the core modules, this resource ensures you are fully prepared for questions on Python's import system, relative vs. absolute imports, and the use of __name__ and __init__.py. It also covers the essential tools for a Python developer, including pip for package installation, the creation of virtual environments, and standard packaging practices using and . Each question includes a clear, correct answer and an in-depth rationale that explains not just the "what," but the "why." This approach helps you understand the underlying concepts, identify common pitfalls, and reinforce your knowledge, ensuring you are ready to pass the certification exam on your first attempt.

Vista previa del contenido

PCAP-31-03 - MODULE 1 - MODULES,
PACKAGES & PIP|TEST BANK- 250 QUESTIONS
WITH CORRECT ANSWERS AND RATIONALES
2026/2027

---



TOPIC A: Basic Import Mechanics (Questions 1-25)



1. What is the primary purpose of the `import` statement in Python?

- A) To execute a system shell command

- B) To bring a module's namespace into the current namespace

- C) To delete an unused variable

- D) To compile Python bytecode

Correct Answer: B

Rationale: The `import` statement loads a module and makes its objects
(functions, classes, variables) available to the current script, effectively
bringing its namespace into scope.



2. Which syntax correctly imports only the `sqrt` function from the `math`
module?

- A) `import sqrt from math`

- B) `from math import sqrt`

- C) `import math.sqrt`

,- D) `include math.sqrt`

Correct Answer: B

Rationale: The `from ... import ...` syntax is specifically designed to import
specific attributes directly into the current namespace without importing the
entire module.



3. What happens when you use `import math` and then try to call `sqrt(9)`
without prefixing it?

- A) It prints 3.0 successfully

- B) It raises a `NameError` because `sqrt` is not defined in the global
namespace

- C) It automatically imports sqrt as well

- D) It raises a `SyntaxError`

Correct Answer: B

Rationale: When you use `import math`, the `sqrt` function is bound to the
`math` namespace. You must call it as `math.sqrt(9)`. Calling `sqrt(9)`
searches the global namespace and fails.



4. Which statement allows you to call `floor(3.7)` directly without a prefix?

- A) `import math`

- B) `import math as m`

- C) `from math import floor`

- D) `from math import *`

Correct Answer: C (and technically D, but C is the specific correct practice)

,Rationale: `from math import floor` binds the `floor` function directly to the
global namespace, allowing direct calls. While `from math import *` also
does this, it is generally discouraged.



5. What is the effect of the `as` keyword in an import statement (e.g.,
`import numpy as np`)?

- A) It copies the module to a new file named `np.py`

- B) It creates an alias (shortcut) for the module name

- C) It validates the module syntax

- D) It installs the module globally

Correct Answer: B

Rationale: The `as` keyword allows you to assign a different name (alias) to
the imported module, which is useful for shortening long module names or
avoiding naming conflicts.



6. Which of the following is a syntax error?

- A) `import math, sys`

- B) `from math import pi, e`

- C) `import math as m`

- D) `from math import as m`

Correct Answer: D

Rationale: The syntax `from math import as m` is invalid. `as` is used to
alias the module itself (e.g., `import math as m`) or an imported function
(e.g., `from math import sqrt as sq`). The syntax in D is missing the function
name before `as`.

, 7. How does Python handle importing the same module multiple times in a
single script?

- A) It executes the module code multiple times

- B) It raises an `ImportError` on the second attempt

- C) It imports it once and caches it in `sys.modules`

- D) It creates a separate copy for each import

Correct Answer: C

Rationale: Python uses a caching mechanism. The first import executes the
module code; subsequent imports simply retrieve the cached module object
from `sys.modules`, preventing redundant execution.



8. Which built-in function returns a list of all names defined in the current
local namespace?

- A) `locals()`

- B) `globals()`

- C) `dir()`

- D) `vars()`

Correct Answer: C

Rationale: While `locals()` and `globals()` return dictionaries, `dir()` without
arguments returns a sorted list of names in the current local scope. When
used with a module argument, it lists the module's attributes.



9. What will `dir(math)` return after importing `math`?

- A) A list of all file names in the math directory

Información del documento

Subido en
27 de agosto de 2026
Número de páginas
107
Escrito en
2026/2027
Tipo
Examen
Contiene
Preguntas y respuestas
$17.49

¿Documento equivocado? Cámbialo gratis Dentro de los 14 días posteriores a la compra y antes de descargarlo, puedes elegir otro documento. Puedes gastar el importe de nuevo.
Escrito por estudiantes que aprobaron
Inmediatamente disponible después del pago
Leer en línea o como PDF

Vendido
0
Seguidores
1
Artículos
65
Última venta
-



Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes