PCPP-32-101 Exam Questions & Answers
PCPP1 - Certified Professional in Python Programming 1 • Python Institute
100% money-back guarantee
Sample PCPP-32-101 Questions
Practice with real exam-style questions, each with the verified correct answer and explanation.
The following snippet represents one of the OOP pillars Which one is that?

The given code snippet demonstrates the concept of encapsulation in object-oriented programming. Encapsulation refers to the practice of keeping the internal state and behavior of an object hidden from the outside world and providing a public interface for interacting with the object. In the given code snippet, the__init__andget_balancemethods provide a public interface for interacting with instances of theBankAccountclass, while the__balanceattribute is kept hidden from the outside world by using a double underscore prefix.
What is true about the unbind () method? (Select two answers.)
Option B is true because theunbind()method is invoked from within a widget's object1.
Option D is true because theunbind()method needs the event name as an argument1.
Theunbind()method in Tkinter is used to remove a binding between an event and a function. It can be invoked from within a widget's object when a binding is no longer needed. The method requires the event name as an argument to remove the binding for that specific event. For example:
button = tk.Button(root, text='Click me')
button.bind('<Button-1>', callback_function) # bind left mouse click event to callback_function
button.unbind('<Button-1>') # remove the binding for the left mouse click event
What is true about the unbind_all () method?
(Select two answers.)
The unbind_all() method in Tkinter is used to remove all event bindings from a widget. It is a method of the widget object and can be called on any widget in the Tkinter application. Therefore, option A is the correct answer.
Option B is incorrect because the method can be called on any widget, not just the main window widget.
Option C is correct as unbind_all() does not take any parameters.
Option D is incorrect because the method only removes event bindings and does not cause the widgets to disappear.
So, the correct answers are A and C.
Tkinter documentation:https://docs.python.org/3/library/tkinter.html#event-bindings
Tkinter tutorial:https://www.python-course.eu/tkinter_events_binds.php
Which of the following methods allow you to load a configuration using ConfigParser? (Select two answers.)
ConfigParser is a built-in library in Python that allows you to read and write configuration files. The read method is used to read the configuration file which can be in any of the supported file formats, such as INI, YAML, and JSON. The read_dict method is used to read the configuration from a Python dictionary. The read_conf and read_str options are not valid methods in the ConfigParser module.
Therefore, the correct options to load a configuration using ConfigParser are A. read and D. read_string.
Analyze the following snippet and decide whether the code is correct and/or which method should be distinguished as a class method.

The correct answer isB. The getNumberofCrosswords() method should be decorated with @classmethod. In the given code snippet, thegetNumberofCrosswordsmethod is intended to be a class method that returns the value of thenumberofcrosswordsclass variable. However, the method is not decorated with the@classmethoddecorator and does not take aclsparameter representing the class itself. To makegetNumberofCrosswordsa proper class method, it should be decorated with@classmethodand take aclsparameter as its first argument.
1. ThegetNumberofCrosswords()method should be decorated with@classmethod.
This is because thegetNumberofCrosswords()method is intended to access the class-level variablenumberofcrosswords, but it is defined as an instance method, which requires an instance of the class to be created before it can be called. To make it work as a class-level method, you can define it as a class method by adding the@classmethoddecorator to the function.
Here's an example of how to definegetNumberofCrosswords()as a class method:
class Crossword:
numberofcrosswords = 0
def __init__(self, author, title):
self.author = author
self.title = title
Crossword.numberofcrosswords += 1
@classmethod
def getNumberofCrosswords(cls):
return cls.numberofcrosswords
In this example,getNumberofCrosswords()is defined as a class method using the@classmethoddecorator, and theclsparameter is used to access the class-level variablenumberofcrosswords.
Official Python documentation on Classes:https://docs.python.org/3/tutorial/classes.html
Get access to all 45 verified questions with detailed answers.
Unlock All PCPP-32-101 Questions