Browse all practice questions for the Certified Professional in Python Programming Level 1 (PCPP1) Practice Exam. Search by topic, open any question and review its full explanation, then test yourself in the practice quiz.

Certified Professional in Python Programming Level 1 (PCPP1) Practice Exam course image
All questions

These questions are part of the practice quiz. Start practicing

  • How are protected attributes named according to the material?
  • To include a specific attribute from the LogRecord in the log format, which syntax is used?
  • What best defines the value of an object?
  • Which library and function would you use to parse XML from a string in Python?
  • Which of the following describes private attributes according to the material?
  • In Python, __call__ is executed when which event occurs?
  • Six hexadecimal digits representing a color code correspond to which color model components?
  • socket.gaierror is a subclass of which built-in exception class?
  • Polymorphism can be realized through which two mechanisms?
  • Which code snippet correctly demonstrates sending JSON data in an HTTP POST using the requests module?
  • In the given class hierarchy, the ElectricCar class inherits from both Car and Vehicle. Which statement is correct?
  • Which statement correctly describes the relationship between id() and the is operator?
  • Which exception attribute contains the error message string?
  • In HTTP URLs, what does the hostname localhost refer to?
  • Which Python data structure maps to a JSON object?
  • Which attribute is automatically set to the exception being handled when a new exception is raised during exception handling?
  • Which HTTP method is used to delete data from a server?
  • Which HTTP status code indicates that the server understood the request but refuses to authorize it?
  • Which naming style is recommended for Python module names?
  • What happens when you run import this in Python?
  • The deleter method for a property is defined using which decorator?
  • What will Statistics([]).calculate_average() return given the implementation that returns None when there is no data?
  • Given a logger configured with level WARNING, which messages will appear?
  • Which HTTP status code indicates a server error?
  • In the provided example, which line prints the actual error message from the exception?
  • Which snippet correctly defines an Employee class with a calculate_salary method that returns hourly_rate multiplied by hours_worked?
  • Which statement about an object's identity is true?
  • Which description best matches the __getitem__ method's purpose?
  • Which statement about method overloading is correct?
  • Which function can be used to retrieve an attribute by name at runtime?
  • Which form of polymorphism allows the object to decide which form of a function to implement at compile time via overloading as well as run-time via overriding?
  • Which of the following objects is not typically serializable by Python's pickle module?
  • What is the magic method name for addition operator overloading in Python?
  • Which values map to JSON booleans true and false when encoding Python objects?
  • Which attribute prefix indicates a private name in Python through name mangling?
  • Which special method handles access to a non-existing attribute?
  • Which method is invoked when indexing into an object using square brackets?
  • What does status code 200 indicate?
  • Which status code indicates that the requested resource could not be found?
  • Which method defines how the abs() function behaves for an object?
  • Which code is for Created and indicates a new resource created?
  • Which ConfigParser method returns a string value for a given key?
  • Which code snippet follows PEP 8 recommendations for comparing to the None object?
  • In a client-server scenario where the server sends data in chunks and the client uses recv(), which statement is correct?
  • Which Python module provides built-in support for JSON serialization and deserialization?
  • Which status code indicates Unauthorized access?
  • What is the socket type for TCP sockets?
  • In a Standards Track Python Enhancement Proposal (PEP), what sequence describes its typical lifecycle before release?
  • Which function call demonstrates proper deserialization of JSON data from a file using the json module?
  • Which statement best describes shallow copy behavior?
  • Which library is designed for parsing and creating XML data and includes the fromstring() function?
  • In a server socket, which method is used to accept a connection from a client?
  • What does ACID stand for in the context of SQLite transactions?
  • Using Python's xml.etree.ElementTree, which expression extracts the text of the grandchild element of the child with id='2'?
  • How should block comments be formatted in Python code?
  • What does 2xx indicate?
  • In designing a RESTful API for a social platform, which networking concept is most relevant for operations like creating posts and retrieving followed users' posts?
  • Which statement about the __repr__ method is true?
  • Which logging level has the lowest priority?
  • Which class allows writing dictionaries to a CSV file where keys represent column headers?
  • In JSON, which type corresponds to Python lists and tuples when serialized?
  • In Python, which operator tests identity (whether two variables refer to the same object)?
  • In the given example, what concept allows perform_action to operate on both Duck and Robot objects?
  • Which implementation best adds an is_even() method to a subclass of int that returns True for even numbers and False for odd numbers?
  • In Python, which library is commonly used to make HTTP requests to REST APIs?
  • Which statement about Python import style aligns with PEP 8 recommendations?
  • Which statement about metaclasses is true?
  • What does an HTTP 2xx status code signify?
  • When breaking a line in Python, where should a binary operator be placed?
  • What does json.dumps do in Python?
  • Which statement is true about how Python lists map to JSON when serialized?
  • Which statement describes operator overloading in Python?
  • Which HTTP method is typically used to submit data from a client to a server to create a new resource?
  • Which of the following are examples of serialization formats mentioned in practice?
  • Which code snippet creates the most basic class by calling type()?
  • Which code is used for Created resources?
  • How would you correctly call the calculate_average() method from an instance of the Statistics class?
  • What is the correct order of decorators to control access to a specific attribute via property, setter and deleter?
  • What is the result of the given Diamond problem MRO code?
  • Which statement about the Python built-in type() function is correct?
  • In SQLite, what does the connection string ':memory:' signify?
  • Which function allows you to retrieve an attribute value by name stored in a string?
  • Which attribute of an exception object holds the line number where the exception was raised?
  • 3xx status codes indicate what?
  • How can type() be used in Python beyond inspecting objects?
  • What are the three arguments required by type() to create a new class?
  • Python uses a small set of rules to convert Python data to JSON. Which Python type maps to the JSON 'object' type?
  • In a list subclass that defines an add(value) method which calls self.append(value), what is the practical implication?
  • Which syntax retrieves the host option from the postgresql section using a ConfigParser?
  • Which instance attributes are conventionally protected in Python?
  • What does the id() function return in Python?
  • Which socket method allows you to send data to a given address?
  • Which special method is used to customize subclass checks for issubclass()?
  • What is the __new__() method primarily used for in Python classes?
  • What will happen when you modify a class attribute via a @classmethod and then access it from two instances?
  • What does the __getitem__ method enable for a Python object?
  • Which approach would you use to handle exceptions raised during socket operations in a multi-threaded Python application to ensure thread safety?
  • Which statement about the __class__ attribute is true?
  • What is the purpose of transaction demarcation in a database?
  • Which statement describes the difference between json.dump and json.dumps in Python?
  • Which of the following statements correctly describes the relationship between method overriding and method overloading in Python?
  • Which code connects to an in-memory SQLite database?
  • In the given SQLite code snippet, which line should replace the '???' to properly prepare for SQL commands?
  • Which HTTP method is used to create or update a resource at a target location?
  • Where should a function's docstring be placed to be recognized as the function's documentation?
  • According to PEP 8, where should an inline comment be written?
  • Which special method handles isinstance() function calls?
  • Which method is called when assigning to an item, e.g., container[key] = value?
  • How are private attributes named according to the material?
  • In JSON, how are Python booleans represented?
  • Which statement is true about Python logging levels?
  • Which security concept is most relevant for securing payment transactions in a RESTful API?
  • How can you access the docstring of a Python function using the function object?
  • What is the recommended maximum line length in PEP 8?
  • Which HTTP method is used to remove a resource in the provided examples?
  • According to PEP 8 guidelines, which change would improve readability when naming an internal instance variable?
  • When a subclass defines its own class attribute with the same name as a base class attribute, what happens?
  • Which status code specifically indicates that a resource could not be found on the server?
  • Inheritance primarily promotes which programming practice?
  • What is the maximum decimal value representable by six hexadecimal digits?
  • Which statement about SQLite is true?
  • Which status code indicates that a new resource has been created?
  • What will be the value of result after executing the following Python code: def add_values(*args, **kwargs): return sum(args) + kwargs.get('bonus', 0) def calculate_total(a, b, c, bonus=0): return add_values(a, b, c, bonus=bonus) result = calculate_total(1, 2, 3, bonus=5)
  • What is the __class__ special attribute used for?
  • Which method does dir() utilize to list an object's attributes?
  • What does the expression isinstance(True, int) evaluate to?
  • Which of the following statements about *args and **kwargs is true?
  • Which statement correctly characterizes HTTP?
  • Which statement about UDP is true?
  • Which of the following is a form of inheritance listed in the material?
  • Which accessor is used to reach a private attribute named __price defined in a class named Laptop using Python's name mangling?
  • What is the __init__ method used for in Python classes?
  • Which of the following is a principle from The Zen of Python?
  • Which status code represents an Internal Server Error?
  • What is the primary benefit of encapsulation?
  • Which statement about an abstract class is true?
  • From a networking perspective, which statement is accurate about TCP/IP in relation to RESTful APIs?
  • What does the return annotation '-> int' signify in a function signature?
  • According to PEP 8, what indentation style should be used?
  • Which code snippet correctly demonstrates creating a TCP server socket?
  • Which statement best describes a characteristic feature of SQLite databases?
  • Which snippet correctly implements calculate_average using calculate_sum with *args?
  • Which HTTP method is used to send data to a server for processing, often used when submitting forms?
  • Which of the following is one of the guiding principles from PEP 20, The Zen of Python?
  • According to PEP 8, what is the recommended order of imports?
  • Which status code indicates unauthorized access?
  • What does the call sqlite3.connect('example.db') do in Python?
  • Which statement correctly represents the relationship between Department and Professor?
  • What is the primary purpose of the @property decorator in Python?
  • Which of the following is NOT a correct mapping between Python types and JSON types?
  • In CRUD, which operation is part of the Create?
  • Which statement describes json.dump's behavior when writing to a file object?
  • To ensure a critical error from a specific module goes to a separate log file, which approach is best?
  • What is the purpose of __str__(self) in Python?
  • __name__ attribute is used to get the name of which of the following?
  • Which XPath expression would select the names of all universities located in Cambridge, MA?
  • Which function converts a JSON-formatted string into a Python object?
  • Which statement correctly describes connection-oriented communication?
  • What is the result of the following code snippet: title = ['Python', 'Course', [3, 10, 0]]; var = title[:]; title[2][1] = 11; What will be printed for title and var?
  • In Python, __init__(self) is used for which purpose?
  • Which statement aligns with the Pythonic approach to namespaces and the use of global variables?
  • Which module provides the Abstract Base Class (ABC) machinery in Python?
  • Which statement best describes the difference between a class variable and an instance variable in Python?
  • Which statement about Python type hints is true?
  • Which json method parses a JSON string into a Python object?
  • Which XPath expression selects the grandchild of the child element with id='2'?
  • What does id(obj) return in Python?
  • Which method should return an iterator for a container?
  • What does the __bases__ attribute of a Python class object return?
  • What does the __bases__ attribute represent for a class?
  • In Python, which data type collects extra positional arguments with *args?
  • Which method is responsible for providing a readable string representation of an object, used by str()?
  • Which statement is true about static methods in Python regarding their parameters?
  • When you want to serialize multiple Python objects to disk with a dictionary-like interface, which module is appropriate?
  • Which statement about json.dumps() is correct?
  • Which network programming paradigm is most suitable for handling a large number of concurrent connections efficiently in Python using non-blocking I/O and coroutines?
  • If a user-defined class does not implement __add__, what happens when you use the + operator with two instances?
  • Which import form is generally discouraged in Python due to namespace pollution?
  • Which naming style does PEP 8 recommend for Python package names?
  • Which 1xx code indicates that the request is informational and being processed?
  • Which line retrieves the root element from an ElementTree after parsing an XML document?
  • Given reply = requests.get('http://python.org:80'), how can you read the content of the server's response?
  • SSH is primarily used for which purpose?
  • Which statement best describes TCP/IP in the context of network communication?
  • Which status code means Not Found?
  • Which ConfigParser method writes the configured data to disk?
  • In YAML configuration, what does the ${name} syntax indicate?
  • Which copy operation is known to have the worst performance for large, nested data structures?
  • In the URL http://python.org:80, port 80 is commonly used for which protocol default?
  • What is the primary role of the cursor object in SQLite operations?
  • Which status code indicates a successful response where a new resource has been created?
  • Which Python value corresponds to the JSON null value?
  • Which statement about shallow copies of lists containing nested mutable objects is true?
  • In xml.etree.ElementTree, which method returns the first matching element for a given XPath?
  • Which code snippet correctly deserializes the data from data.json into a Python dictionary?
  • Which LogRecord attribute stores the line number where the log call was made?
  • Which decorator is used to define the setter for a property?
  • Which of the following is true about the HTTP status code 200 OK?
  • What does the __dict__ attribute of an object represent?
  • Which HTTP header specifies the format of the data being returned in a response?
  • In a snippet that creates File objects for 'script.py', 'win.js', 'data.txt', 'login.py' and prints the language attribute for those with language set, which sequence of language values is printed?
  • How does Python handle method overloading?
  • Which function is used to add a new user by sending data to a server in the provided examples?
  • When a function is decorated with multiple decorators, which describes the correct call sequence?
  • Which statement correctly contrasts json.load and json.loads?
  • The 5xx class of HTTP status codes indicates which type of response?
  • According to common Python style guidelines, which naming style is recommended for function and variable names?
  • Which statement about binding of classmethod and staticmethod is accurate?
  • In Python, what is the role of the first parameter in a class method?
  • Which concept is primarily about DNS authentication and integrity and not directly related to REST API payments?
  • Which function can be used to get a list of object-specific methods?
  • Which exception attribute contains the name of the file where the exception occurred?
  • In the shallow vs deep copy example, after modifying a[2][0] = 5 on the original, which lists reflect the change in their nested lists?
  • Which statement about FTP is accurate?
  • Which statement correctly describes the attributes __cause__, __context__, and __traceback__ used in exception chaining?
  • Which statement best describes method overriding in a subclass?
  • What is the result of serializing the list [4, 3, 5.5, False, None, 'code', '5', {'one': 'uno'}] to JSON using json.dumps?
  • Which protocol is designed for secure remote login and secure data transmission?
  • Which code indicates a bad request?
  • The Style Guide for Python Code recommends a naming convention for variables and functions. Which statement is true?
  • In object-oriented programming, which statement about method overriding is true?
  • Which argument of logging.basicConfig controls the format of log messages?
  • What is printed by the following expressions: print(Container.__class__), print(cont.__class__), print(cont.container_type.__class__)?
  • Run-time polymorphism is typically achieved through which mechanism?
  • Which statement correctly defines a label in programming terms?
  • Why is placing logging configuration in a module using basicConfig not recommended for directing logs to a separate file?
  • Contrast __str__ and __repr__. Which statement is accurate?
  • What does socket.accept() return when called on a listening server socket?
  • What does HTTP status code 500 indicate?
  • The args attribute of an exception object stores what?
  • Which magic method is used to implement the behavior of the index operator [] on objects in Python?
  • Which statement about SMTP is accurate?
  • Which json module method reads data from a JSON file and parses it into a Python object?
  • What does the @classmethod decorator do?
  • In Python, __eq__(self, other) is used to implement what behavior?
  • Given two classes Pet and Dog as shown, what is the output when rex = Dog('Rex'); print(rex.name); print(Pet.name); print(Dog.name)?
  • How are public attributes defined according to the material?
  • Which description best defines a metaclass?
  • In the PEP lifecycle, what stage immediately follows Final?
  • Which two magic methods should be implemented to allow iteration over a class using a for loop?
  • In INI files, what interpolation syntax is used?
  • According to PEP 8, how many blank lines should surround top-level function and class definitions?
  • What is the result of json.loads('[4, 3, \"5.5\", true, null, \"code\", {\"one\": \"uno\"}]') in Python?
  • Which is a method used to send data over a socket?
  • Which SQL statements are used for explicit transaction demarcation?
  • Which term refers to the rules that define how computers should exchange data?
  • A subclass must do what with an abstract method defined in an abstract class?
  • Which statement aligns with PEP 8 recommendations for comments in Python code?
  • Which statement about object identity is accurate?
  • What does the HTTP status code 404 Not Found signify?
  • In Python's logging module, what is the primary role of a Formatter?
  • Which status code indicates a redirection?
  • In Python's socket module, what does AF_INET specify?
  • Which method does the csv.writer object provide to write a single row to the CSV?
  • Which class is used to write rows to a CSV file by creating an instance with a file object?
  • What is the default formatting of the root logger in Python's logging module?
  • Which statement about PEP 1 is accurate?
  • In the metaclass example, what does the statement attrs['add'] = lambda self, value: self.append(value) accomplish?
  • In the observable variable example, what is the role of the add_observer() method?
  • Which operation guarantees that changes to the copy do not affect the original?
  • What does ET.parse('products.xml') return?
  • Which statement best describes how the calculate_average method computes the mean when data is present?
  • What does the HTTP status code 401 Unauthorized indicate?
  • What is the primary purpose of csv.DictWriter?
  • What does the __class__ attribute return for an object?
  • The getter method is typically implemented using which decorator?
  • Which statement about the IP protocol is true?
  • In the provided File class example, which extension triggers the language attribute to be set to 'Python'?
  • Which HTTP method is used to update existing data on a server?
  • Which code snippet correctly creates a Tkinter window titled "My Application" and runs the main loop?
  • Which statement about the conventional name for the first parameter of a class method is accurate?
  • Which of the following Python types maps to the JSON 'number' type?
  • Which 1xx code denotes that the request was received and is being processed?
  • In Python, which naming convention indicates a protected member by convention?
  • Which Python type maps to the JSON 'array' type during JSON encoding?
  • What is the primary purpose of PEP 8?
  • Which attribute provides access to the namespace dictionary containing an object's attributes and methods?
  • Which parameter is essential to specify the column order when using csv.DictWriter?
  • What is the proper Python idiom to check that a variable x is not None?
  • In xml.etree.ElementTree, what type is returned by ET.fromstring(xml_string)?
  • What behavior does the CustomList class gain through its metaclass?
  • What does the __dict__ attribute contain?
  • Which module is described as a powerful and flexible serialization module in Python?
  • When called on a class, what does the dir() function return?
  • Which statement is true about copy.deepcopy()?
  • Which code means Forbidden?
  • Which of the following is the correct SQLite command to update the Grade of the student with ID 123 to 'A' in the Students table?
  • What is the result of the following code when printing the host from the postgresql section with a DEFAULT host of localhost? print(config['postgresql']['host'])
  • Which HTTP method is used to request data from a resource?
  • In the URL http://localhost:5000, what does the number 5000 represent?
  • For a class that inherits from a base class, what does __bases__ return?
  • Which concept describes creating a new class that inherits from an existing class?
  • Which statement about csv.DictWriter usage is true?
  • Which statement best describes HTTP 200 OK?
  • What does 404 Not Found mean?
  • Which of the following is a standard Tkinter widget?
  • Which naming style does PEP 8 recommend for module names?
  • Name mangling prefixes private attributes with what to avoid naming conflicts?
  • Which Python type maps to a JSON array, similar to a Python list?
  • What does encapsulation mean in object-oriented programming?
  • Which built-in function can be used to list the methods and attributes of a class in Python?
  • If a subclass does not implement all abstract methods, what happens at instantiation?
  • Which statement best describes a static method in Python?
  • xml.etree.ElementTree provides a function to parse XML from a string. Which distribution statement is correct?
  • What does 4xx indicate?
  • In Python type hints, what does the annotation x: int denote?
  • In Python, which operator triggers the __eq__ method on an object?
  • What is the role of the root logger in Python's logging module?
  • What does DNS do?
  • The @abstractmethod decorator is part of which module in Python, and what is its primary purpose?
  • What is the correct life cycle order for a Python Enhancement Proposal (PEP) before inclusion in a release?
  • Which HTTP method is used to fetch data from a server in the provided examples?
  • Which is a common use case for a classmethod?
  • Which of the following is the base class for all socket objects in the Python socket module?
  • In .ini configuration files, what syntax denotes interpolation using another key value?
Subscribe

Get the latest from Passetra

You can unsubscribe at any time. Read our privacy policy