PrepIQ PCAP 31 03 PCAP Certified Associate in Python Programming Certification Learning Co, Exams of Technology

The PrepIQ PCAP 31 03 Certified Associate in Python Programming Ultimate Exam is a comprehensive preparation resource for Python learners. This ultimate exam covers syntax, data structures, functions, modules, and object-oriented programming. Learners gain practical coding skills and problem-solving abilities. Ideal for aspiring developers, this resource supports certification and Python proficiency.

Typology: Exams

2025/2026

Available from 04/25/2026

shilpi-jain-3
shilpi-jain-3 🇮🇳

2.5

(11)

80K documents

1 / 81

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
PrepIQ PCAP 31 03 PCAP Certified
Associate in Python Programming
Certification Learning Course
Ultimate Exam
**Question 1. Which special method is called to create a new instance before
__init__ is executed?**
A) __new__
B) __init__
C) __call__
D) __repr__
Answer: A
Explanation: __new__ is a static method that actually creates the object; __init__
then initializes it.
**Question 2. In Python, which dunder method enables the use of the + operator
for custom objects?**
A) __add__
B) __sum__
C) __plus__
D) __concat__
Answer: A
Explanation: Defining __add__(self, other) allows instances to be added with the
+ operator.
**Question 3. What does the @property decorator allow you to do?**
A) Create a read-only attribute
B) Define a method that can be accessed like an attribute
C) Automatically delete an attribute when it goes out of scope
D) Bind a function to a class at runtime
Answer: B
Explanation: @property turns a method into a getter accessed like an attribute,
supporting optional setters and deleters.
**Question 4. Which naming convention triggers name mangling in a class?**
A) _single_leading_underscore
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
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d
pf4e
pf4f
pf50
pf51

Partial preview of the text

Download PrepIQ PCAP 31 03 PCAP Certified Associate in Python Programming Certification Learning Co and more Exams Technology in PDF only on Docsity!

Associate in Python Programming

Certification Learning Course

Ultimate Exam

Question 1. Which special method is called to create a new instance before init is executed? A) new B) init C) call D) repr Answer: A Explanation: new is a static method that actually creates the object; init then initializes it. Question 2. In Python, which dunder method enables the use of the + operator for custom objects? A) add B) sum C) plus D) concat Answer: A Explanation: Defining add(self, other) allows instances to be added with the

  • operator. Question 3. What does the @property decorator allow you to do? A) Create a read-only attribute B) Define a method that can be accessed like an attribute C) Automatically delete an attribute when it goes out of scope D) Bind a function to a class at runtime Answer: B Explanation: @property turns a method into a getter accessed like an attribute, supporting optional setters and deleters. Question 4. Which naming convention triggers name mangling in a class? A) _single_leading_underscore

Associate in Python Programming

Certification Learning Course

Ultimate Exam

B) __double_leading_underscore C) double_trailing_underscore D) no underscore Answer: B Explanation: Attributes with two leading underscores are mangled to _ClassName__attr to avoid accidental overrides. Question 5. What is the method resolution order (MRO) used for in multiple inheritance? A) Determining the order of attribute deletion B) Deciding which base class’s method is called first C) Sorting class names alphabetically D) Managing garbage collection Answer: B Explanation: MRO defines the linearized order Python follows to resolve attribute and method lookups in a hierarchy. Question 6. Which function returns the MRO of a class as a tuple? A) class.mro() B) class.mro C) inspect.mro(class) D) type.mro(class) Answer: B Explanation: The mro attribute holds the tuple of classes that Python will search for attributes. Question 7. In the abc module, which decorator marks a method as abstract? A) @abstractmethod B) @abstractproperty C) @abstractclassmethod

Associate in Python Programming

Certification Learning Course

Ultimate Exam

Question 11. The expression (a is b) tests for what? A) Equality of values B) Identity of objects C) Membership in a collection D) Presence of attribute a in b Answer: B Explanation: The is operator checks whether two variables reference the same object in memory. Question 12. Which module provides functions for shallow and deep copying? A) copy B) shutil C) pickle D) json Answer: A Explanation: copy.copy produces a shallow copy; copy.deepcopy produces a deep copy. Question 13. When defining a custom exception hierarchy, which built-in class should be the ultimate base? A) Exception B) BaseException C) RuntimeError D) SystemExit Answer: B Explanation: All built-in exceptions inherit from BaseException; user-defined exceptions should normally inherit from Exception (a subclass of BaseException) to be catchable by except Exception.

Associate in Python Programming

Certification Learning Course

Ultimate Exam

Question 14. In a chained exception, which attribute holds the original exception that caused the current one? A) cause B) context C) traceback D) original Answer: A Explanation: Using raise NewError from OriginalError sets cause to OriginalError, enabling explicit chaining. Question 15. Which attribute of an exception object contains the traceback object? A) traceback B) stack C) info D) tb Answer: A Explanation: traceback stores the traceback chain that can be inspected with traceback module functions. Question 16. Which PEP introduced the style guide that defines indentation, naming, and whitespace rules? A) PEP 8 B) PEP 20 C) PEP 257 D) PEP 484 Answer: A Explanation: PEP 8 is the official Python style guide. Question 17. According to PEP 20, which principle states “Simple is better than complex”?

Associate in Python Programming

Certification Learning Course

Ultimate Exam

Answer: A Explanation: PyLint analyzes code for style and logical errors, including PEP 8 compliance. Question 21. In tkinter, which method starts the event loop? A) mainloop() B) run() C) start() D) loop() Answer: A Explanation: root.mainloop() enters the Tkinter event processing loop. Question 22. Which geometry manager places widgets in a grid of rows and columns? A) pack() B) grid() C) place() D) flow() Answer: B Explanation: grid() organizes widgets in a tabular layout. Question 23. Which widget is best suited for displaying an image that can be drawn upon? A) Label B) Canvas C) Button D) Entry Answer: B Explanation: Canvas provides drawing primitives and can display images.

Associate in Python Programming

Certification Learning Course

Ultimate Exam

Question 24. Which method binds a left-mouse click event to a callback function on a widget? A) bind("", callback) B) on("", callback) C) connect("", callback) D) listen("click", callback) Answer: A Explanation: bind() registers a handler for the given Tkinter event pattern. Question 25. Which tkinter variable class should be used to track integer values? A) StringVar B) IntVar C) DoubleVar D) BooleanVar Answer: B Explanation: IntVar holds integer values and updates associated widgets automatically. Question 26. In socket programming, which method puts a server socket into listening mode? A) listen() B) bind() C) accept() D) connect() Answer: A Explanation: listen(backlog) tells the OS to accept incoming connection requests. Question 27. Which socket method is used by a client to initiate a connection to a server? A) bind()

Associate in Python Programming

Certification Learning Course

Ultimate Exam

Answer: A Explanation: json.dumps serializes a Python object to a JSON formatted string. Question 31. When parsing XML with ElementTree, which method retrieves the text content of an element? A) .text B) .value C) .content D) .data Answer: A Explanation: Element.text holds the textual data inside an XML element. Question 32. In the requests library, which argument is used to send JSON data in a POST request? A) data= B) json= C) payload= D) body= Answer: B Explanation: requests.post(url, json=obj) automatically serializes obj to JSON and sets the appropriate header. Question 33. Which HTTP status code indicates that the request was successful and a new resource was created? A) 200 B) 201 C) 202 D) 204 Answer: B Explanation: 201 Created signals that the server has fulfilled the request and created a new resource.

Associate in Python Programming

Certification Learning Course

Ultimate Exam

Question 34. In SQLite, which method finalizes a transaction and makes changes permanent? A) commit() B) save() C) apply() D) flush() Answer: A Explanation: Connection.commit writes all pending changes to the database file. Question 35. Which SQLite cursor method returns an iterator over query results without loading them all into memory? A) fetchall() B) fetchone() C) fetchmany() D) execute() returns an iterator when using .fetchall()? Answer: C Explanation: fetchmany(size) yields rows in batches, reducing memory consumption. Question 36. When writing CSV files with the csv module, which dialect should be used for Excel-compatible files? A) unix B) excel C) excel_tab D) default Answer: B Explanation: csv.excel is the default dialect that matches Excel’s CSV format. Question 37. Which method of ConfigParser reads configuration from a string rather than a file?

Associate in Python Programming

Certification Learning Course

Ultimate Exam

Answer: B Explanation: datetime.utcnow() returns the current time in UTC without applying local timezone conversion. Question 41. Which io class provides a in-memory binary stream? A) StringIO B) BytesIO C) TextIOWrapper D) BufferedReader Answer: B Explanation: BytesIO implements a file-like object for binary data held in memory. Question 42. Which protocol does the pickle module use to serialize objects? A) JSON B) XML C) Binary protocol (specific to pickle) D) CSV Answer: C Explanation: pickle serializes Python objects using its own binary protocol versions (0–5). Question 43. What is the primary difference between pickle.dump() and pickle.dumps()? A) dump writes to a file object; dumps returns a bytes object B) dump is for text, dumps is for binary C) dump encrypts data, dumps does not D) dump works only on dictionaries, dumps works on any object Answer: A Explanation: dump(obj, file) writes serialized data to a file-like object; dumps(obj) returns the serialized bytes.

Associate in Python Programming

Certification Learning Course

Ultimate Exam

Question 44. Which module provides a persistent, dictionary-like object storage using pickle internally? A) shelve B) dbm C) sqlite D) json Answer: A Explanation: shelve creates a persistent mapping where values are pickled automatically. Question 45. Which built-in function can be used to check if an object is an instance of a given class or its subclass? A) isinstance() B) issubclass() C) type() D) hasattr() Answer: A Explanation: isinstance(obj, cls) returns True if obj’s type is cls or a subclass thereof. Question 46. Which decorator from functools can turn a function into a cached version that stores results? A) @lru_cache B) @memoize C) @cached D) @cacheable Answer: A Explanation: functools.lru_cache caches function calls based on arguments.

Associate in Python Programming

Certification Learning Course

Ultimate Exam

B) A proxy object that delegates attribute lookup to the next class in the MRO C) The name of the superclass as a string D) The instance’s dict Answer: B Explanation: super() provides a temporary object that searches for attributes in the MRO after the current class. **Question 51. Which of the following statements about shallow copy is correct? ** A) All nested objects are duplicated. B) Only the top-level container is copied; nested objects are shared. C) It creates a completely independent clone. D) It is performed by the copy.deepcopy function. Answer: B Explanation: Shallow copy copies the container but references the same inner objects. Question 52. In a try/except block, which clause is executed when an exception is raised but not caught by any preceding except clauses? A) else B) finally C) except: D) except BaseException: Answer: D Explanation: A bare except or except BaseException catches any exception not matched earlier. Question 53. Which attribute of an exception object contains the message passed when it was raised? A) args[0] B) message

Associate in Python Programming

Certification Learning Course

Ultimate Exam

C) msg D) text Answer: A Explanation: Exception.args is a tuple of arguments; the first element is the message string. Question 54. Which PEP introduced type hinting to Python? A) PEP 8 B) PEP 20 C) PEP 257 D) PEP 484 Answer: D Explanation: PEP 484 defines the typing module and syntax for optional static type hints. Question 55. Which of the following is a correct type hint for a function that returns a list of strings? A) -> List[str] B) -> list(str) C) -> List of str D) -> [str] Answer: A Explanation: Using typing.List, the annotation is -> List[str]. Question 56. In Pylint, which message code indicates a missing docstring? A) C B) W C) E D) R Answer: A

Associate in Python Programming

Certification Learning Course

Ultimate Exam

Question 60. In the requests library, which attribute of the Response object contains the HTTP status code? A) status B) code C) status_code D) http_status Answer: C Explanation: response.status_code returns the numeric HTTP status. Question 61. Which HTTP header is commonly used to indicate the media type of the request body? A) Accept B) Content-Type C) Authorization D) User-Agent Answer: B Explanation: Content-Type tells the server the MIME type of the payload (e.g., application/json). Question 62. Which method of a socket object shuts down both reading and writing? A) close() B) shutdown(socket.SHUT_RDWR) C) abort() D) disconnect() Answer: B Explanation: shutdown with SHUT_RDWR disables further sends and receives. Question 63. Which function from the json module can parse a JSON string into a Python dictionary? A) loads()

Associate in Python Programming

Certification Learning Course

Ultimate Exam

B) load() C) decode() D) parse() Answer: A Explanation: json.loads(s) deserializes a JSON formatted string. Question 64. Which XML parsing method returns an ElementTree object from a file path? A) parse() B) fromstring() C) load() D) read() Answer: A Explanation: ElementTree.parse('file.xml') reads and parses the XML file. Question 65. In SQLite, which command is used to remove a table from the database? A) DROP TABLE table_name; B) DELETE TABLE table_name; C) REMOVE TABLE table_name; D) ERASE TABLE table_name; Answer: A Explanation: DROP TABLE permanently deletes the table schema and data. Question 66. Which method of a csv.DictReader object returns the next row as a dictionary? A) next() B) readrow() C) nextrow() D) fetch()