Python Institute PCPP-32-101 PCPP1 - Certified Professional in Python Programming 1 Exam Practice Test

Page: 1 / 14
Total 45 questions
Question 1

Select the true statements about sockets. (Select two answers)



Answer : A, D

1. A socket is a connection point that enables a two-way communication between programs running in a network.

This statement is true because a socket is a software structure that serves as an endpoint for sending and receiving data across a network. A socket is defined by an application programming interface (API) for the networking architecture, such as TCP/IP.A socket can be used to establish a communication channel between two programs running on the same or different network nodes12.

2. A socket is always the secure means by which computers on a network can safely communicate, without the risk of exposure to an attack.

This statement is false because a socket by itself does not provide any security or encryption for the data transmitted over the network. A socket can be vulnerable to various types of attacks, such as eavesdropping, spoofing, hijacking, or denial-of-service.To ensure secure communication, a socket can use additional protocols or mechanisms, such as SSL/TLS, SSH, VPN, or firewall3.

3. A socket is a connection point that enables a one-way communication only between remote processes.

This statement is false because a socket can enable both one-way and two-way communication between processes running on the same or different network nodes. A socket can be used for connection-oriented or connectionless communication, depending on the type of protocol used.For example, TCP is a connection-oriented protocol that provides reliable and bidirectional data transfer, while UDP is a connectionless protocol that provides unreliable and unidirectional data transfer12.

4. A socket can be used to establish a communication endpoint for processes running on the same or different machines.

This statement is true because a socket can be used for inter-process communication (IPC) within a single machine or across different machines on a network.A socket can use different types of addresses to identify the processes involved in the communication, such as IP address and port number for network sockets, or file name or path for Unix domain sockets12.


1: https://en.wikipedia.org/wiki/Network_socket2: https://www.geeksforgeeks.org/socket-in-computer-network/3: https://www.tutorialspoint.com/what-is-a-network-socket-computer-networks

Question 2

Which of the following values can be returned by the messagebox. askquestion () method?



Answer : C

Themessagebox.askquestion()method in Python's tkinter library displays a message box with a specified question and two response buttons labeled 'Yes' and 'No'. It returns a string indicating which button was selected - either 'yes' or 'no'.

This function is used to ask questions to the user that have only two options: YES or NO.It can be used to ask the user if they want to continue or if they want to submit something1.


Question 3

Select the true statement about PEP 8 recommendations related to line breaks and binary operators.



Question 4

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



Answer : A, D

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.


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

Question 5

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



Question 6

Select the true statement about the___name___attribute.



Answer : D

The true statement about the__name__attribute isD.nameis 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.


Official Python documentation on Classes:https://docs.python.org/3/tutorial/classes.html#class-objects

Question 7

Which sentence about the property decorator is false?



Answer : A

The@propertydecorator should be defined after the method that is responsible for setting an encapsulated attribute is a false sentence. In fact, the@propertydecorator should be defined before the method that is used to set the attribute value. The@propertydecorator and the setter and deleter methods work together to create an encapsulated attribute, which is used to provide control over the attribute's value.


Official Python documentation on Property:https://docs.python.org/3/library/functions.html#property

The@propertydecorator is used to designate a method as a getter for an instance attribute. The method decorated with@propertyshould be defined before any setter or deleter methods for the same attribute.

Page:    1 / 14   
Total 45 questions