- Home
- Python Institute
- PCPP1
- PCPP-32-101
- PCPP-32-101 - PCPP1 – Certified Professional in Python Programming 1
Python Institute PCPP-32-101 PCPP1 – Certified Professional in Python Programming 1 Exam Practice Test
PCPP1 – Certified Professional in Python Programming 1 Questions and Answers
What does the term deserialization mean? Select the best answer.
Options:
It is a process of creating Python objects based on sequences of bytes.
It is a process of assigning unique identifiers to every newly created Python object
It is another name for the data transmission process
It is a process of converting the structure of an object into a stream of bytes
Answer:
AExplanation:
Answer: A. Deserialization is the process of converting data that has been serialized 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.
If w is a correctly created main application window, which method would you use to foe both of the main window's dimensions?
Options:
w. f ixshape ()
w. f ixdim ()
w. resizable ()
w.makewindow ()
Answer:
CExplanation:
C. w.resizable()
The resizable() method takes two Boolean arguments, width and height , that specify whether the main window can be resized in the corresponding directions. Passing False to both arguments makes the main window non-resizable, whereas passing True to both arguments (or omitting them) makes the window resizable.
Here is an example that sets the dimensions of the main window to 500x400 pixels and makes it non-resizable:
import tkinter as tk
root = tk. Tk ()
root. geometry ( "500x400" )
root. resizable (False, False)
root. mainloop ()
The following JSON string:
{ 1 }
Options:
is erroneous
is an object
is an array
is an integer
Answer:
AExplanation:
The correct answer is A because { 1 } is not valid JSON syntax. In JSON, curly braces represent an object, but an object must contain name-value pairs. Property names must be strings enclosed in double quotation marks, followed by a colon and a value, such as {"id": 1}. The expression { 1 } contains a numeric value inside braces without a property name or colon, so it cannot be parsed as a JSON object. It is also not an array, because JSON arrays use square brackets, such as [1]. It is not an integer either, because the braces change the syntax. Therefore, this JSON string is erroneous.
A socket object is usually created by which one of the following invocations?
Options:
socket. socket (socket_domain, socket_type)
socket = socket. socket (socket_number)
socket = socket. socket (socket_domain, socket_type, server_address)
socket = socket.socket(server address)
Answer:
AExplanation:
A socket object is usually created using the socket() constructor provided by the socket module in Python. The correct invocation is socket.socket(socket_domain, socket_type) . This creates a new socket object with the specified socket domain and type.
What is a static method?
Options:
A method that works on the class itself
A method decorated with the @method trait
A method that requires no parameters referring to the class itself
A method that works on class objects that are instantiated
Answer:
CExplanation:
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.
What is true about the constructor’s argument, which sets the button’s title to a desired string?
Options:
It is the second argument of the constructor.
It is the third argument of the constructor.
It is a keyword argument named title.
It is a keyword argument named text.
Answer:
DExplanation:
The correct answer is D. In Tkinter, the text displayed on a Button widget is normally configured with the keyword argument text. For example, Button(root, text="OK") creates a button whose visible caption is OK. This value is not determined by the second or third positional argument in a reliable, recommended way. Tkinter widget constructors are designed to receive the parent widget first and then configuration options as keyword arguments. The keyword title is not the standard option for button captions; titles are associated more with windows, such as setting a top-level window title. For a button’s label, the correct constructor argument is text.
Select the true statements about the connection-oriented and connectionless types of communication. (Select two answers.)
Options:
In the context of TCP/IP networks, the communication side that initiates a connection is called the client, whereas the side that answers the client is called the server
Connectionless communications are usually built on top of TCP
Using walkie-talkies is an example of a connection-oriented communication
A phone call is an example of a connection-oriented communication
Answer:
A, DExplanation:
A. In the context of TCP/IP networks, the communication side that initiates a connection is called the client, whereas the side that answers the client is called the server.
This statement is true because TCP/IP networks use a client-server model to establish connection-oriented communications. The client is the device or application that requests a service or resource from another device or application, which is called the server. The server responds to the client’s request and provides the service or resource. For example, when you browse a website using a web browser, the browser acts as a client and sends a request to the web server that hosts the website. The web server acts as a server and sends back the requested web page to the browser 1 .
B. Connectionless communications are usually built on top of TCP.
This statement is false because TCP (Transmission Control Protocol) is a connection-oriented protocol that requires establishing and terminating a connection before and after sending data. Connectionless communications are usually built on top of UDP (User Datagram Protocol), which is a connectionless protocol that does not require any connection setup or teardown. UDP simply sends data packets to the destination without checking if they are received or not 2 .
C. Using walkie-talkies is an example of a connection-oriented communication.
This statement is false because using walkie-talkies is an example of a connectionless communication. Walkie-talkies do not establish a dedicated channel or connection between the sender and receiver before transmitting data. They simply broadcast data over a shared frequency without ensuring that the receiver is ready or available to receive it. The sender does not know if the receiver has received the data or not 3 .
D. A phone call is an example of a connection-oriented communication.
This statement is true because a phone call is an example of a connection-oriented communication. A phone call requires setting up a circuit or connection between the caller and callee before exchanging voice data. The caller and callee can hear each other’s voice and know if they are connected or not. The phone call also requires terminating the connection when the conversation is over 4 .
Analyze the following function and choose the statement that best describes it.

Options:
It is an example of a decorator that accepts its own arguments.
It is an example of decorator stacking.
It is an example of a decorator that can trigger an infinite recursion.
The function is erroneous.
Answer:
AExplanation:
In the given code snippet, the repeat function is a decorator that takes an argument num_times specifying the number of times the decorated function should be called. The repeat function returns an inner function wrapper_repeat that takes a function func as an argument and returns another inner function wrapper that calls func num_times times.
The provided code snippet represents an example of a decorator that accepts its own arguments. The @decorator_function syntax is used to apply the decorator_function to the some_function function. The decorator_function takes an argument arg1 and defines an inner function wrapper_function that takes the original function func as its argument. The wrapper_function then returns the result of calling func , along with the arg1 argument passed to the decorator_function .
Here is an example of how to use this decorator with some_function :
@ decorator_function ( "argument 1" )
def some_function ():
return "Hello world"
When some_function is called, it will first be passed as an argument to the decorator_function . The decorator_function then adds the string "argument 1" to the result of calling some_function() and returns the resulting string. In this case, the final output would be "Hello world argument 1" .
What is a___traceback___?
(Select two answers )
Options:
An attribute owned by every exception object
A special method delivered by the traceback module to retrieve a full list of strings describing the traceback
An attribute that is added to every object when the traceback module is imported
An attribute that holds interesting information that is particularly useful when the programmer wants to store exception details in other objects
Answer:
A, DExplanation:
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.
Select the true statements about the json.loads() function.
(Select two answers.)
Options:
It takes Python data as its argument.
It returns a JSON string.
It takes a JSON string as its argument.
It returns a Python entity.
Answer:
C, DExplanation:
The correct answers are C and D. The json.loads() function is used for JSON deserialization. It accepts a JSON-formatted string, bytes, or bytearray and converts that serialized JSON data into an equivalent Python object. For example, a JSON object becomes a Python dictionary, a JSON array becomes a Python list, JSON strings become Python strings, and JSON numbers become Python numeric values. Option A describes json.dumps(), which takes Python data and serializes it into JSON text. Option B is also incorrect because returning a JSON string is the job of json.dumps(), not json.loads(). Therefore, json.loads() takes JSON text as input and returns a Python entity.
What will be the content of the cars.xml file when you run the following code?
import xml.etree.ElementTree as ET
root = ET.Element('data')
car_1 = ET.SubElement(root, 'car', {'brand': 'Audi'})
car_2 = ET.SubElement(root, 'car', {'brand': 'Volkswagen'})
tree = ET.ElementTree(root)
tree.write('cars.xml', 'UTF-8', True)
Options:
< data > < car brand="Audi" / > < car brand="Volkswagen" / > < /data >
< ?xml version='1.0'? >
< data > < car brand="Audi" / > < car brand="Volkswagen" / > < /data >
< ?xml version='1.0' encoding='UTF-8'? >
< data > < car brand="Audi" / > < car brand="Volkswagen" / > < /data >
< ?xml? >
< data > < car brand="Audi" / > < car brand="Volkswagen" / > < /data >
Answer:
CExplanation:
The correct answer is C. The code creates an XML root element named data and then adds two child elements named car. Each car element receives a brand attribute, one with the value Audi and the other with the value Volkswagen. The statement tree.write('cars.xml', 'UTF-8', True) writes the XML document using UTF-8 encoding and explicitly enables the XML declaration through the third argument. Because the XML declaration is enabled, the output begins with < ?xml version='1.0' encoding='UTF-8'? > . The generated XML body then contains the data element with two self-closing car child elements. Options without the encoding declaration are therefore incomplete.
What is the result of the following code?
import configparser
config = configparser.ConfigParser()
config['DEFAULT'] = {}
config['mysql'] = {}
config['postgresql'] = {}
config['redis'] = config['postgresql']
print(config.sections())
Options:
['DEFAULT', 'mysql', 'postgresql', 'redis']
['mysql', 'postgresql', 'redis']
['DEFAULT', 'mysql', 'postgresql', 'postgresql']
['mysql', 'postgresql', 'postgresql']
Answer:
BExplanation:
The correct answer is B. The ConfigParser.sections() method returns a list of section names, but it does not include the special DEFAULT section. Therefore, even though config['DEFAULT'] = {} is present, DEFAULT is excluded from the printed result. The code then creates three regular sections: mysql, postgresql, and redis. Assigning config['redis'] = config['postgresql'] creates or updates a separate section named redis using the values from the postgresql section; it does not duplicate the section name postgresql in the section list. Therefore, the output contains only the normal section names: ['mysql', 'postgresql', 'redis'] .
Which sentence about the ©property decorator is false?
Options:
The ©property decorator should be defined after the method that is responsible for setting an encapsulated attribute.
The @property decorator designates a method which is responsible for returning an attribute value
The ©property decorator marks the method whose name will be used as the name of the instance attribute
The ©property decorator should be defined before the methods that are responsible for setting and deleting an encapsulated attribute
Answer:
AExplanation:
The @property decorator should be defined after the method that is responsible for setting an encapsulated attribute is a false sentence. In fact, the @property decorator should be defined before the method that is used to set the attribute value. The @property decorator and the setter and deleter methods work together to create an encapsulated attribute, which is used to provide control over the attribute's value.
Select the true statements about the json.-dumps () function. (Select two answers.)
Options:
It returns a JSON string.
It returns a Python entity.
It takes a JSON string as its argument
It takes Python data as its argument.
Answer:
A, DExplanation:
The json.dumps() function is used to convert a Python object into a JSON string 1 . It takes Python data as its argument, such as a dictionary or a list, and returns a JSON string.
Which of the following examples using line breaks and different indentation methods are compliant with PEP 8 recommendations? (Select two answers.)
Options:
my_dict = {
"X": "180.A",
"Y": "206.P",
"Z": "12.C"
}
spam = my_function(arg_one,
arg_two,
arg_three,
arg_four)
foo = my_function
(arg_one, arg_two,
arg_three, arg_four
)
my_dict = { "A" : "1", "B" : "2", "C" : "1" }
Answer:
A, BExplanation:
The correct answers are A and B. Option A uses a clean multi-line dictionary layout, placing each key-value pair on its own line and aligning the closing brace clearly. This is readable and consistent with PEP 8’s preference for clear continuation formatting. Option B is also compliant because continuation lines are aligned with the opening delimiter of the function call, which is an accepted PEP 8 style. Option C is not compliant because the function call is split awkwardly, making the call structure unclear and damaging readability. Option D uses unnecessary spaces inside braces and around dictionary colons; PEP 8 discourages extraneous whitespace in expressions and dictionary displays.
Select the correct statements about the csv module.
(Select two answers.)
Options:
The DictReader method always gets the header from the first line in the file.
A reader object maps each row to a list of strings.
It is possible to create a DictWriter object without specifying a header.
A DictReader object maps each row to a dict.
Answer:
B, DExplanation:
The correct answers are B and D. In Python’s csv module, a normal csv.reader object reads each CSV row as a list of strings, so option B is true. A csv.DictReader object reads each row into a dictionary, using field names as keys, so option D is also true. Option A is false because DictReader does not always take headers from the first row; field names can be provided explicitly through the fieldnames argument. Option C is false because DictWriter requires field names so it knows which dictionary keys correspond to CSV columns and in what order they should be written. This distinction between row lists and row dictionaries is central to CSV processing.
What is true about a parameter named cls?
Options:
It is usually used as a reference to a class instance.
It is usually used as the first parameter of a static method.
It is usually used as the first parameter of a class method.
It is the name of a module that delivers an abstract method decorator.
Answer:
CExplanation:
The correct answer is C because cls is the conventional first parameter name used in class methods. A class method is defined with the @classmethod decorator, and Python automatically passes the class itself as the first argument when the method is called. This is similar to how self represents the instance in instance methods, but cls represents the class object, not an individual object. Static methods are different because they receive neither self nor cls automatically; they behave like regular functions placed inside a class namespace. Option A is incorrect because a class instance is conventionally referenced by self, not cls. Option D is unrelated to Python’s method model.
Which methods can be invoked in order to draw a triangle?
(Select two answers.)
Options:
create_shape()
create_line()
create_triangle_shape()
create_polygon()
Answer:
B, DExplanation:
The correct answers are B and D. In Tkinter’s Canvas widget, there is no built-in method named create_shape() or create_triangle_shape(). A triangle can be drawn either with create_line() by connecting three line segments between three coordinate points, or with create_polygon() by providing three vertices. create_polygon() is the more direct method because a triangle is a polygon with three sides, and Tkinter can render it as a filled or outlined shape. create_line() is also valid when the programmer manually draws the three sides and closes the shape. Therefore, the valid Canvas methods for producing a triangle are create_line() and create_polygon().
Select the true statements related to PEP 8 programming recommendations for code writing. (Select two answers:)
Options:
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.
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)).
You should write code in a way that favors the CPython implementation over PyPy, Cython. and Jython.
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:
B, DExplanation:
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 .
What is wrong with the following snippet?
class A:
def run(self):
print("A is running")
class B(A):
def run(self):
print("B is running")
class C(A, B):
def fly(self):
print("C is flying")
c = C()
Options:
There is no run() method defined for the C class.
It causes MRO inconsistency.
Nothing. The code is fine.
There are no __init__() methods — each class should implement this method.
Answer:
BExplanation:
The issue is method resolution order, commonly called MRO. In Python multiple inheritance, the interpreter must build a consistent linear inheritance path for the class. Here, B already inherits from A, meaning B must appear before A in the resolution order. However, class C(A, B) asks Python to resolve A before B. These two requirements conflict, so Python cannot create a valid MRO for class C. This results in a TypeError related to inconsistent method resolution order. The absence of an __init__() method is not a problem because Python supplies a default initializer. Also, C can inherit run() if the inheritance order is valid.
Unlock PCPP-32-101 Features
- PCPP-32-101 All Real Exam Questions
- PCPP-32-101 Exam easy to use and print PDF format
- Download Free PCPP-32-101 Demo (Try before Buy)
- Free Frequent Updates
- 100% Passing Guarantee by Activedumpsnet
Questions & Answers PDF Demo
- PCPP-32-101 All Real Exam Questions
- PCPP-32-101 Exam easy to use and print PDF format
- Download Free PCPP-32-101 Demo (Try before Buy)
- Free Frequent Updates
- 100% Passing Guarantee by Activedumpsnet