Docsity

PCAP Style Practice Exam (Certified Associate Python Programmer) - Modules, OOP, Excepti, Exams of Computer Science

Toggle sidebar
bg1
PCAP Style Practice Exam (Certified
Associate Python Programmer) - Modules,
OOP, Exceptions, Strings, Generators - 300
Original Questions with Answers
Original intermediate Python practice; not an official Python Institute exam
300 Multiple-Choice Practice Questions
with Answer Key and Explanations
2026 Edition
PCAP Style Practice Exam (Certified Associate Python Programmer) - Modules, OOP, Exceptions, Strings, Generators - 300 Original Questions with
Answers | Page 1
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28

Partial preview of the text

Download PCAP Style Practice Exam (Certified Associate Python Programmer) - Modules, OOP, Excepti and more Exams Computer Science in PDF only on Docsity!

PCAP Style Practice Exam (Certified

Associate Python Programmer) - Modules,

OOP, Exceptions, Strings, Generators - 300

Original Questions with Answers

Original intermediate Python practice; not an official Python Institute exam

300 Multiple-Choice Practice Questions

with Answer Key and Explanations

2026 Edition PCAP Style Practice Exam (Certified Associate Python Programmer) - Modules, OOP, Exceptions, Strings, Generators - 300 Original Questions with

Exam Overview This original practice exam covers modules and packages, exceptions, strings, object-oriented programming, generators, iterators and closures, files and standard library, data structures and functional tools, and scenario judgement. It is not an official Python Institute exam and does not reproduce proprietary content. Behavior can vary by version, so please confirm details against current Python documentation. Exam PCAP Style Practice Exam (Certified Associate Python Programmer) - Modules, OOP, Exceptions, Strings, Generators - 300 Original Questions with Answers Intended for Python programmers studying intermediate Python concepts Number of questions 300 multiple-choice (four options, one best answer) Content areas 9 Suggested time 5 hours (about 60 seconds per question) Suggested passing target 80% or higher (240 of 300) Answer format The correct answer and explanation appear directly after each question

Content Blueprint

Content area Questions Share of exam Modules and Packages 33 11% Exceptions 33 11% Strings and Text 33 11% Object-Oriented Programming 33 11% Generators, Iterators and Closures 33 11% Files and Standard Library 33 11% Data Structures and Built-ins 33 11% Functional Tools and Idioms 33 11% Scenarios and Best Practices 36 12%

How to Use This Exam

 Cover the answer lines with a sheet of paper and attempt each question before checking.  Work one content area at a time, or take all questions in one timed sitting to simulate test day.  Mark every question you miss or guess on, then reread its explanation and the related reference material.  Repeat the missed questions after a few days; aim to explain why each wrong option is wrong.

Reference Materials Used

 General Python 3 concepts (confirm against current Python documentation) Note: This is an independent practice resource written to the published content areas for this exam. It is not affiliated with or endorsed by the testing organization, and it does not contain actual exam questions. Laws, codes, fees and guidelines change; confirm current requirements with the official candidate handbook and references. PCAP Style Practice Exam (Certified Associate Python Programmer) - Modules, OOP, Exceptions, Strings, Generators - 300 Original Questions with

Section 1: Modules and Packages

1. A module is: A. A class only B. A function only C. A file containing Python definitions D. A variable only Correct answer: C. A file containing Python definitions Explanation: Mod. 2. The import statement: A. Loads a module B. Deletes a module C. Prints a module D. Hides a module Correct answer: A. Loads a module Explanation: Mod. 3. from module import name: A. Imports nothing B. Imports a specific name C. Deletes name D. Prints name Correct answer: B. Imports a specific name Explanation: Mod. 4. import module as alias: A. Deletes the module B. Prints it C. Hides it D. Gives a module a shorter name Correct answer: D. Gives a module a shorter name Explanation: Mod. 5. A package is: A. A directory of modules B. A single function C. A single class D. A variable Correct answer: A. A directory of modules Explanation: Mod. PCAP Style Practice Exam (Certified Associate Python Programmer) - Modules, OOP, Exceptions, Strings, Generators - 300 Original Questions with

6. The file init.py: A. Deletes a package B. Prints a package C. Hides it D. Marks and initializes a package Correct answer: D. Marks and initializes a package Explanation: Mod. 7. sys.path: A. Lists variables B. Lists classes C. Lists directories searched for modules D. Lists bills Correct answer: C. Lists directories searched for modules Explanation: Mod. 8. The variable name in the main script equals: A. "main" B. "main" C. "script" D. "module" Correct answer: B. "main" Explanation: Mod. 9. if name == "main": A. Runs always B. Runs never C. Runs code only when executed directly D. Imports public names from a module Correct answer: C. Runs code only when executed directly Explanation: Mod. 10. Module objects are cached in: A. sys.path B. sys.argv C. sys.exit D. sys.modules Correct answer: D. sys.modules Explanation: Mod. PCAP Style Practice Exam (Certified Associate Python Programmer) - Modules, OOP, Exceptions, Strings, Generators - 300 Original Questions with

16. import star: A. Imports nothing B. Deletes names C. Prints names D. Imports public names from a module Correct answer: D. Imports public names from a module Explanation: Mod. 17. dir(module): A. Deletes names B. Prints module C. Hides names D. Lists names in a module Correct answer: D. Lists names in a module Explanation: Mod. 18. help(module): A. Deletes docs B. Shows documentation C. Hides docs D. Prints bills Correct answer: B. Shows documentation Explanation: Mod. 19. Docstrings: A. Document modules, classes and functions B. Delete code C. Hide code D. Print bills Correct answer: A. Document modules, classes and functions Explanation: Mod. 20. Module-level variables: A. Are local always B. Are deleted C. Are global within the module D. Are hidden Correct answer: C. Are global within the module Explanation: Mod. PCAP Style Practice Exam (Certified Associate Python Programmer) - Modules, OOP, Exceptions, Strings, Generators - 300 Original Questions with

21. Namespaces: A. Map bills B. Map names to objects C. Map users D. Map prices Correct answer: B. Map names to objects Explanation: Mod. 22. Scopes follow: A. LEGB order B. ABC order C. XYZ order D. Random order Correct answer: A. LEGB order Explanation: Mod. 23. The global keyword: A. Deletes names B. Prints names C. Hides names D. Lets a function assign a module-level name Correct answer: D. Lets a function assign a module-level name Explanation: Mod. 24. The nonlocal keyword: A. Gives a module a shorter name B. Lists names in a module C. Lets a nested function assign an enclosing name D. Marks and initializes a package Correct answer: C. Lets a nested function assign an enclosing name Explanation: Mod. 25. pip: A. Installs third-party packages B. Deletes Python C. Prints Python D. Hides Python Correct answer: A. Installs third-party packages Explanation: Mod. PCAP Style Practice Exam (Certified Associate Python Programmer) - Modules, OOP, Exceptions, Strings, Generators - 300 Original Questions with

31. The math module provides: A. Mathematical functions B. String tools C. File tools D. Network tools Correct answer: A. Mathematical functions Explanation: Mod. 32. The random module provides: A. Cryptographic keys only B. File tools C. Network tools D. Pseudo-random numbers Correct answer: D. Pseudo-random numbers Explanation: Mod. 33. The platform module provides: A. Math functions B. String tools C. Network tools D. System and platform information Correct answer: D. System and platform information Explanation: Mod. PCAP Style Practice Exam (Certified Associate Python Programmer) - Modules, OOP, Exceptions, Strings, Generators - 300 Original Questions with

Section 2: Exceptions

34. An exception is: A. An event that disrupts normal flow B. A variable C. A module D. A bill Correct answer: A. An event that disrupts normal flow Explanation: Exc. 35. try block: A. Handles exceptions B. Ends programs C. Contains code that may raise exceptions D. Runs if no exception occurred Correct answer: C. Contains code that may raise exceptions Explanation: Exc. 36. except block: A. Raises exceptions B. Handles raised exceptions C. Ends programs D. Are stored in args Correct answer: B. Handles raised exceptions Explanation: Exc. 37. else block in try: A. Runs if no exception occurred B. Runs on error C. Runs never D. A file path does not exist Correct answer: A. Runs if no exception occurred Explanation: Exc. 38. finally block: A. Runs only on errors B. Runs never C. Runs regardless of exceptions D. Handles raised exceptions Correct answer: C. Runs regardless of exceptions Explanation: Exc. PCAP Style Practice Exam (Certified Associate Python Programmer) - Modules, OOP, Exceptions, Strings, Generators - 300 Original Questions with

44. ValueError occurs when: A. A name is missing B. A file is missing C. A key is missing D. A value has the right type but inappropriate content Correct answer: D. A value has the right type but inappropriate content Explanation: Exc. 45. TypeError occurs when: A. An operation uses an inappropriate type B. A value is empty C. A key is missing D. A file is missing Correct answer: A. An operation uses an inappropriate type Explanation: Exc. 46. KeyError occurs when: A. A list index is out of range B. A file is missing C. A dictionary key is missing D. A name is missing Correct answer: C. A dictionary key is missing Explanation: Exc. 47. IndexError occurs when: A. A key is missing B. A sequence index is out of range C. A name is missing D. A file is missing Correct answer: B. A sequence index is out of range Explanation: Exc. 48. NameError occurs when: A. A key is missing B. An index is out of range C. A file is missing D. A name is not defined Correct answer: D. A name is not defined Explanation: Exc. PCAP Style Practice Exam (Certified Associate Python Programmer) - Modules, OOP, Exceptions, Strings, Generators - 300 Original Questions with

49. AttributeError occurs when: A. A key is missing B. An attribute does not exist C. An index is out of range D. A file is missing Correct answer: B. An attribute does not exist Explanation: Exc. 50. ImportError occurs when: A. An import fails B. A key is missing C. An index is out of range D. A name is typed Correct answer: A. An import fails Explanation: Exc. 51. FileNotFoundError occurs when: A. A key is missing B. An index is out of range C. A file path does not exist D. A name is typed Correct answer: C. A file path does not exist Explanation: Exc. 52. StopIteration signals: A. A crash B. A key error C. A file error D. End of an iterator Correct answer: D. End of an iterator Explanation: Exc. 53. KeyboardInterrupt occurs when: A. A key is missing B. An index is out of range C. The user interrupts the program D. A file is missing Correct answer: C. The user interrupts the program Explanation: Exc. PCAP Style Practice Exam (Certified Associate Python Programmer) - Modules, OOP, Exceptions, Strings, Generators - 300 Original Questions with

59. The cause attribute: A. Holds the file B. Holds bills C. Holds users D. Holds the chained cause Correct answer: D. Holds the chained cause Explanation: Exc. 60. assert statement: A. Runs if no exception occurred B. Tests a condition and raises AssertionError on failure C. Should be preferred over bare except D. Manages resources via context managers Correct answer: B. Tests a condition and raises AssertionError on failure Explanation: Exc. 61. AssertionError: A. Is raised by imports B. Is raised by files C. Is raised by names D. Is raised by failed assertions Correct answer: D. Is raised by failed assertions Explanation: Exc. 62. with statement: A. Deletes resources B. Prints resources C. Manages resources via context managers D. Hides resources Correct answer: C. Manages resources via context managers Explanation: Exc. 63. Context manager protocol: A. Uses init only B. Uses enter and exit C. Uses del D. Uses str Correct answer: B. Uses enter and exit Explanation: Exc. PCAP Style Practice Exam (Certified Associate Python Programmer) - Modules, OOP, Exceptions, Strings, Generators - 300 Original Questions with

64. Traceback: A. Shows the call stack at an error B. Shows bills C. Shows users D. Shows prices Correct answer: A. Shows the call stack at an error Explanation: Exc. 65. Warnings module: A. Raises errors always B. Deletes code C. Issues non-fatal warnings D. Prints bills Correct answer: C. Issues non-fatal warnings Explanation: Exc. 66. Logging module: A. Deletes events B. Records events at levels C. Hides events D. Prints bills Correct answer: B. Records events at levels Explanation: Exc. PCAP Style Practice Exam (Certified Associate Python Programmer) - Modules, OOP, Exceptions, Strings, Generators - 300 Original Questions with

72. Slicing s[1:3]: A. Returns 1 to 3 inclusive B. Deletes them C. Prints them D. Returns characters at index 1 and 2 Correct answer: D. Returns characters at index 1 and 2 Explanation: Str. 73. Slice with step s[::2]: A. Reverses the string B. Returns every second character C. Deletes them D. Prints them Correct answer: B. Returns every second character Explanation: Str. 74. Reverse a string: A. s.reverse() B. reverse(s) C. s[::-1] D. s.flip() Correct answer: C. s[::-1] Explanation: Str. 75. str.upper(): A. Returns an uppercase copy B. Changes in place C. Returns the last character D. Substitutes placeholders in a string Correct answer: A. Returns an uppercase copy Explanation: Str. 76. str.lower(): A. Changes in place B. Splits into a list of substrings C. Is a common Unicode encoding D. Returns a lowercase copy Correct answer: D. Returns a lowercase copy Explanation: Str. PCAP Style Practice Exam (Certified Associate Python Programmer) - Modules, OOP, Exceptions, Strings, Generators - 300 Original Questions with

77. str.strip(): A. Removes leading and trailing whitespace B. Removes all spaces C. Tests if all characters are digits D. Returns the last character Correct answer: A. Removes leading and trailing whitespace Explanation: Str. 78. str.split(): A. Joins a list B. Capitalizes the first character C. Splits into a list of substrings D. Centers within a width Correct answer: C. Splits into a list of substrings Explanation: Str. 79. str.join(): A. Returns the character for a code point B. Joins an iterable of strings with a separator C. An immutable sequence of characters D. Returns a copy with a replaced by b Correct answer: B. Joins an iterable of strings with a separator Explanation: Str. 80. str.replace(a, b): A. Changes in place B. Returns characters at index 1 and 2 C. Tests letters or digits only D. Returns a copy with a replaced by b Correct answer: D. Returns a copy with a replaced by b Explanation: Str. 81. str.find(x): A. Raises on missing B. Removes leading and trailing whitespace C. Centers within a width D. Returns the index or - Correct answer: D. Returns the index or - Explanation: Str. PCAP Style Practice Exam (Certified Associate Python Programmer) - Modules, OOP, Exceptions, Strings, Generators - 300 Original Questions with