python institute pcpp-32-101 practice test

Exam Title: Certified Professional in Python Programming 1

Last update: Nov 27 ,2025
Question 1

Select the true statement about the___name___attribute.

  • A. ___name___is a special attribute, which is inherent for both classes and instances, and it contains information about the class to which a class instance belongs.
  • B. ___name is a special attribute, which is inherent for both classes and instances, and it contains a dictionary of object attributes.
  • C. __name___is a special attribute, which is inherent for classes and it contains information about the class to which a class instance belongs.
  • D. __name___is a special attribute, which is inherent for classes, and it contains the name of a class.
Answer:

D


Explanation:
The true statement about the __name__ attribute is D. name is a special attribute, which is inherent
for classes, and it contains the name of a class. The __name__ attribute is a special attribute of
classes that contains the name of the class as a string.
The __name__ attribute is a special attribute in Python that is available for all classes, and it contains
the name of the class as a string. The __name__ attribute can be accessed from both the class and its
instances using the dot notation.
Reference:
Official Python documentation on Classes:
https://docs.python.org/3/tutorial/classes.html#class-
objects

vote your answer:
A
B
C
D
A 0 B 0 C 0 D 0
Comments
Question 2

What is a static method?

  • A. A method that works on the class itself
  • B. A method decorated with the @method trait
  • C. A method that requires no parameters referring to the class itself
  • D. A method that works on class objects that are instantiated
Answer:

C


Explanation:
A static method is a method that belongs to a class rather than an instance of the class. It is defined
using the @staticmethod decorator and does not take a self or cls parameter. Static methods are
often used to define utility functions that do not depend on the state of an instance or the class itself.

vote your answer:
A
B
C
D
A 0 B 0 C 0 D 0
Comments
Question 3

What is true about type in the object-oriented programming sense?

  • A. It is the bottommost type that any object can inherit from.
  • B. It is a built-in method that allows enumeration of composite objects
  • C. It is the topmost type that any class can inherit from
  • D. It is an object used to instantiate a class
Answer:

C


Explanation:
In Python, type is the built-in metaclass that serves as the base class for all new-style classes. All
new-style classes in Python, including built-in types like int and str, are instances of
the type metaclass and inherit from it.

vote your answer:
A
B
C
D
A 0 B 0 C 0 D 0
Comments
Question 4

What does the term deserialization mean? Select the best answer.

  • A. It is a process of creating Python objects based on sequences of bytes.
  • B. It is a process of assigning unique identifiers to every newly created Python object
  • C. It is another name for the data transmission process
  • D. It is a process of converting the structure of an object into a stream of bytes
Answer:

A


Explanation:
Deserialization is the process of converting data that has been serialized
Explanation:or encoded in a specific format, back into its original form as an object or a data
structure in memory. In Python, this typically involves creating Python objects based on sequences of
bytes that have been serialized using a protocol such as JSON, Pickle, or YAML.
For example, if you have a Python object my_obj and you want to serialize it to a JSON string, you
might do something like this:
import json
serialized_obj = json.dumps(my_obj)
To deserialize the JSON string back into a Python object, you would use the json.loads() method:
deserialized_obj = json.loads(serialized_obj)
This would convert the JSON string back into its original Python object form.
Reference:
Official
Python
Documentation
on
Serialization:
https://docs.python.org/3/library/pickle.html#module-pickle
Real Python Tutorial on Serialization and Deserialization in Python:
https://realpython.com/python-
serialization/
Deserialization is the process of converting a sequence of bytes, such as a file or a network message,
into a Python object. This is the opposite of serialization, which is the process of converting a Python
object into a sequence of bytes for storage or transmission.

vote your answer:
A
B
C
D
A 0 B 0 C 0 D 0
Comments
Question 5

What is a___traceback___?
(Select two answers )

  • A. An attribute owned by every exception object
  • B. A special method delivered by the traceback module to retrieve a full list of strings describing the traceback
  • C. An attribute that is added to every object when the traceback module is imported
  • D. An attribute that holds interesting information that is particularly useful when the programmer wants to store exception details in other objects
Answer:

AD


Explanation:
The correct answers are A. An attribute owned by every exception object and D. An attribute that
holds interesting information that is particularly useful when the programmer wants to store
exception details in other objects. A traceback is an attribute of an exception object that contains a
stack trace representing the call stack at the point where the exception was raised. The traceback
attribute holds information about the sequence of function calls that led to the exception, which can
be useful for debugging and error reporting.

vote your answer:
A
B
C
D
A 0 B 0 C 0 D 0
Comments
Question 6

Which of the following examples using line breaks and different indentation methods are compliant
with PEP 8 recommendations? (Select two answers.)
A)

B)

C)

D)

  • A. Option A
  • B. Option B
  • C. Option C
  • D. Option D
Answer:

BD


Explanation:
The correct answers are B. Option B and D. Option D. Both options B and D are compliant with PEP 8
recommendations for line breaks and indentation. PEP 8 recommends using 4 spaces per indentation
level and breaking lines before binary operators. In option B, the arguments to the print function are
aligned with the opening delimiter, which is another acceptable way to format long lines according to
PEP 8. In option D, the second line is indented by 4 spaces to distinguish it from the next logical line.

vote your answer:
A
B
C
D
A 0 B 0 C 0 D 0
Comments
Question 7

Look at the following examples of comments and docstrings in Python Select the ones that are useful
and compliant with PEP 8 recommendations (Select the two best answers.)
A)

B)

C)

D)

  • A. Option A
  • B. Option B
  • C. Option C
  • D. Option D
Answer:

BD


Explanation:
According to PEP 8 recommendations, the two best options are Option B and Option D.
Option B follows PEP 8’s suggestion that all lines should be limited to 79 characters and for longer
blocks of text like docstrings or comments, the length should be limited to 72 characters1
. Option D
follows PEP 8’s conventions for writing good documentation strings (a.k.a. “docstrings”) which are
immortalized in PEP 257. It suggests writing docstrings for all public modules, functions, classes, and
methods
.

vote your answer:
A
B
C
D
A 0 B 0 C 0 D 0
Comments
Question 8

Select the true statement related to PEP 257.

  • A. String literals that occur immediately after another docstring are called attribute docstrings.
  • B. Attribute docstrings and Additional docstrings are two types of extra docstrings that can be extracted by software tools.
  • C. String Iiterals that occur in places other than the first statement in a module, function, or class definition can act as documentation They are recognized by the Python bytecode compiler and are accessible as runtime object attributes
  • D. String literals that occur immediately after a simple assignment at the top level of a module are called complementary docstrings
Answer:

B


Explanation:
The true statement related to PEP 257 is Option B. According to PEP 257, string literals occurring
elsewhere in Python code may also act as documentation. They are not recognized by the Python
bytecode compiler and are not accessible as runtime object attributes (i.e. not assigned to doc), but
two types of extra docstrings may be extracted by software tools: String literals occurring
immediately after a simple assignment at the top level of a module, class, or init method are called
“attribute docstrings”. String literals occurring immediately after another docstring are called
“additional docstrings”
.

vote your answer:
A
B
C
D
A 0 B 0 C 0 D 0
Comments
Question 9

Select the true statements related to PEP 8 programming recommendations for code writing. (Select
two answers:)

  • A. You should use the not ... is operator (e.g. if not spam is None:), rather than the is not operator (e.g. if spam is not None:), to increase readability.
  • B. You should make object type comparisons using the ismstanceQ method (e.g. if isinstance (obj, int) :) instead of comparing types directly (eg if type(obj) is type(i)).
  • C. You should write code in a way that favors the CPython implementation over PyPy, Cython. and Jython.
  • D. You should not write string literals that rely on significant trailing whitespaces as they may be visually indistinguishable, and certain editors may trim them
Answer:

BD


Explanation:
The two true statements related to PEP 8 programming recommendations for code writing
are Option B and Option D.
Option B is true because PEP 8 recommends making object type comparisons using
the isinstance() method instead of comparing types directly 1
.
Option D is true because PEP 8 recommends not writing string literals that rely on significant trailing
whitespaces as they may be visually indistinguishable, and certain editors may trim them 1
.

vote your answer:
A
B
C
D
A 0 B 0 C 0 D 0
Comments
Question 10

Select the true statements related to PEP 8 naming conventions. (Select two answers.)

  • A. Function and variable names should be lower-case with words separated by underscores.
  • B. You should always use self as the first argument to instance methods, and cls as the first argument to class methods.
  • C. Modules should have short names written in CameICase.
  • D. Constants should be written in all lower-case letters with words separated by underscores
Answer:

AD


Explanation:
Option A is true because PEP 8 recommends that function and variable names should be lowercase,
with words separated by underscores .
Option D is true because PEP 8 recommends that constants should be written in all capital letters
with words separated by underscores .
PEP 8 is the official style guide for Python code. It provides guidelines for how to write readable code
that follows consistent naming conventions. The aim of PEP 8 is to improve the readability of Python
code and make it easier to understand and maintain.
According to PEP 8, variable and function names should be written in all lower-case letters with
words separated by underscores, as stated in A. Constants, which are variables whose value is
expected to remain constant throughout the code, should be written in all upper-case letters with
words separated by underscores, as stated in D.
Reference:
PEP 8 -- Style Guide for Python Code:
https://www.python.org/dev/peps/pep-0008/
Python
Documentation:
https://docs.python.org/3/tutorial/classes.html#classmethods-and-
staticmethods

vote your answer:
A
B
C
D
A 0 B 0 C 0 D 0
Comments
Page 1 out of 4
Viewing questions 1-10 out of 45
Go To
page 2