無料Python Institute PCPP-32-101試験問題と解答トレーニングを提供しています [Q12-Q37]

Share

無料Python Institute PCPP-32-101試験問題と解答トレーニングを提供しています

トップクラスPython Institute PCPP-32-101オンライン問題集


Python Institute PCPP-32-101試験(PCPP1試験とも呼ばれます)は、Pythonプログラミング言語の熟練度をテストするために設計された認定試験です。この試験は、Pythonプログラミングに関する知識とスキルを証明したい個人向けに用意されており、データ型、制御構造、関数、モジュールなど、様々なトピックをカバーしています。


Python InstituteのPCPP-32-101(PCPP1)認定試験は、Pythonプログラミング言語の熟練度を評価するために設計されています。この認定資格は、Pythonプログラミングの知識とスキルを潜在的な雇用主に示したい個人を対象としています。PCPP1認定試験は、Pythonプログラミングに必要な基礎的な知識とスキルを検証するエントリーレベルの認定資格です。

 

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

  • A.
  • B.
  • C.
  • D.

正解:A、B

解説:
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 methods2.


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

  • A. You should not write string literals that rely on significant trailing whitespaces as they may be visually indistinguishable, and certain editors may trim them
  • B. You should write code in a way that favors the CPython implementation over PyPy, Cython. and Jython.
  • C. 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)).
  • D. 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 notNone:), to increase readability.

正解:A、C

解説:
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.


質問 # 14
What will be the content of the co/ors.csv filewhen you run the following code?

A)

B)

C)

D)
An exception will be raised.

  • A. Option C
  • B. Option D
  • C. Option B
  • D. Option A

正解:C


質問 # 15
In the JSON processing context, the term serialization:

  • A. refers to nothing, because there is no such thing as JSON serialization.
  • B. names a process in which a JSON string is turned into Python data.
  • C. names a process in which a JSON string is remodeled and transformed into a new JSON string
  • D. names a process in which Python data is turned into a JSON string.

正解:D

解説:
Explanation
In the JSON processing context, the term serialization: A. names a process in which Python data is turned into a JSON string.
Serialization refers to the process of converting a data object, such as a Python object, into a format that can be easily transferred over a network or stored in a file. In the case of JSON, serialization refers to converting Python data into a string representation using the JSON format. This string can be sent over a network or stored as a file, and later deserialized back into the original Python data object.


質問 # 16
If purple can be obtained from mixing red and blue, which color codes represent the two ingredients? Select two answers)

  • A. #FF0000
  • B. #0000FF
  • C. #FFFFFF
  • D. #000000

正解:A、B


質問 # 17
What isa___traceback___?
(Select two answers )

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

正解:A、B

解説:
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.


質問 # 18
Analyze the following function and choose the statement that best describes it.

  • A. It is an example of a decorator that accepts its own arguments.
  • B. It is an example of decorator stacking.
  • C. The function is erroneous.
  • D. It is an example of a decorator that can trigger an infinite recursion.

正解:A

解説:
Explanation
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")
defsome_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".


質問 # 19
What is the result of the following code?

What is the result of the following code?

  • A. Nothing will be displayed
  • B. Debugging mode has been enabled Loading data...
  • C. Loading data...
  • D. Debugging mode has been enabled

正解:C

解説:
Explanation
This statement is true because the code uses the logging module to create a logger object and set its level to logging.INFO. The logging module provides a way of reporting events that occur during the execution of a program. The logging level determines which events are reported and which are ignored. The logging module defines five levels of severity: DEBUG, INFO, WARNING, ERROR, and CRITICAL. The lower the level, the more events are reported.
The code then uses the logger object to log two messages: one with the level logging.DEBUG and one with the level logging.INFO. The logger object only reports the messages that have a level equal or higher than its own level. Therefore, the message with the level logging.DEBUG is ignored, while the message with the level logging.INFO is reported. The default format for reporting messages is "level name: message". Therefore, the output of the code is:
INFO: Loading data...


質問 # 20
Analyze the following snippet and choose the best statement that describes it.

  • A. varl is the name of a global variable
  • B. Excalibur is the value passed to an instance variable
  • C. Weapon is the value passed to an instance variable
  • D. self. name is the name of a class variable.

正解:B

解説:
Explanation
The correct answer is C. Excalibur is the value passed to an instance variable. In the given code snippet, self.name is an instance variable of the Sword class. When an instance of the Sword class is created with varl = Sword('Excalibur'), the value 'Excalibur' is passed as an argument to the __init__ method and assigned to the name instance variable of the varl object.
The code defines a class called Sword with an __init__ method that takes one parameter name. When a new instance of the Sword class is created with varl = Sword('Excalibur'), the value of the 'Excalibur' string is passed as an argument to the __init__ method, and assigned to the self.name instance variable of the varl object.


質問 # 21
Select the true statement about the socket. gaierror exception.

  • A. It is raised when a system function returns a system-related error.
  • B. It is raised when an address-related error caused by the repr () function occurs.
  • C. It is raised when an address-related error caused by the getaddrinfo () and getnameinfo () functions occurs.
  • D. It is raised when a timeout occurs on a socket.

正解:C

解説:
Explanation
The socket.gaierror exception is raised when an address-related error caused by the getaddrinfo() and getnameinfo() functions occurs. These functions are used to translate hostnames to IP addresses and vice versa, and the gaierror exception is raised if they fail to perform this translation.


質問 # 22
The following snippet represents one of the OOP pillars Which one is that?

  • A. Encapsulation
  • B. Serialization
  • C. Inheritance
  • D. Polymorphism

正解:A

解説:
Explanation
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__ and get_balance methods provide a public interface for interacting with instances of the BankAccount class, while the __balance attribute is kept hidden from the outside world by using a double underscore prefix.


質問 # 23
Select the true statement about composition

  • A. Composition is a concept that promotes code reusability while inheritance promotes encapsulation.
  • B. Composition allows a class to be projected as a container of different classes
  • C. Composition extends a class's capabilities by adding new components and modifying the existing ones.
  • D. Composition is based on the has a relation: so it cannot be used together with inheritance.

正解:B

解説:
Explanation
Composition is an object-oriented design concept that models a has-a relationship. In composition, a class known as composite contains an object of another class known as component. In other words, a composite class has a component of another class1.
Composition allows a class to be projected as a container of different classes.
Composition is a concept in Python that allows for building complex objects out of simpler objects, by aggregating one or more objects of another class as attributes. The objects that are aggregated are generally considered to be parts of the whole object, and the containing object is often viewed as a container for the smaller objects.
In composition, objects are combined in a way that allows for greater flexibility and modifiability than what inheritance can offer. With composition, it is possible to create new objects by combining existing objects, by using a container object to host other objects. By contrast, with inheritance, new objects extend the behavior of their parent classes, and are limited by that inheritance hierarchy.
References:
* Official Python documentation on
Composition: https://docs.python.org/3/tutorial/classes.html#composition
* GeeksforGeeks article on Composition vs
Inheritance: https://www.geeksforgeeks.org/composition-vs-inheritance-python/
* Real Python article on Composition and
Inheritance: https://realpython.com/inheritance-composition-python/


質問 # 24
Which of the following constants will be used if you do riot define the quoting argument in the writer method provided by the csv module?

  • A. csv.QUOTE_NONE
  • B. csv.QUOTE_MINIMAL
  • C. csv.QUOTE_NONNUMERIC
  • D. svQUOTE_ALL

正解:B

解説:
Explanation
If you do not define the quoting argument in the writer method provided by the csv module, the default quoting behavior is set to QUOTE_MINIMAL. This means that fields containing special characters such as the delimiter or newline character will be quoted, while fields that do not contain special characters will not be quoted.


質問 # 25
A socket object is usually created by which one of the following invocations?

  • A. socket = socket. socket (socket_domain, socket_type, server_address)
  • B. socket = socket. socket (socket_number)
  • C. socket = socket.socket(server address)
  • D. socket. socket (socket_domain, socket_type)

正解:D

解説:
Explanation
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.


質問 # 26
Select the true statements about the connection-oriented and connectionless types of communication. (Select two answers.)

  • A. A phone call is an example of a connection-oriented communication
  • B. Connectionless communications are usually built on top of TCP
  • C. 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
  • D. Using walkie-talkies is an example of a connection-oriented communication

正解:A、C

解説:
Explanation
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 browser1.
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 not2.
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 not3.
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 over4.
References:
1: https://www.techtarget.com/searchnetworking/definition/client-server 2:
https://www.javatpoint.com/connection-oriented-vs-connectionless-service 3:
https://en.wikipedia.org/wiki/Walkie-talkie 4: https://en.wikipedia.org/wiki/Telephone_call A is true because in the context of TCP/IP networks, the communication side that initiates a connection is called the client, and the side that answers the client is called the server. This is the basis for establishing a connection-oriented communication.
D is true because a phone call is an example of a connection-oriented communication. Like TCP/IP, a phone call establishes a connection between two devices (in this case, two phones) before communication can occur.
A is true because in the context of TCP/IP networks, the communication side that initiates a connection is called the client, and the side that answers the client is called the server. This is the basis for establishing a connection-oriented communication.
D is true because a phone call is an example of a connection-oriented communication. Like TCP/IP, a phone call establishes a connection between two devices (in this case, two phones) before communication can occur.
B is false because connectionless communications are usually built on top of UDP, not TCP. UDP is a connectionless protocol that does not establish a connection before sending data.
C is false because using walkie-talkies is an example of a connectionless communication. Walkie-talkies do not establish a connection before communication begins, and messages are simply broadcasted to all devices within range.
Here is a sample code in Python using the socket module to create a TCP server and client to demonstrate the connection-oriented communication:
Server-side code:
importsocket
HOST ='127.0.0.1'
PORT =8080
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.bind((HOST, PORT))
s.listen()
conn, addr = s.accept()
with conn:
print('Connected by', addr)
whileTrue:
data = conn.recv(1024)
ifnotdata:
break
conn.sendall(data)
Client-side code:
importsocket
HOST ='127.0.0.1'
PORT =8080
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.connect((HOST, PORT))
s.sendall(b'Hello, world')
data = s.recv(1024)
print('Received',repr(data))
The server listens for incoming connections on port 8080, and when a connection is established, it prints the address of the client that has connected. The server then continuously receives data from the client and sends it back to the client until the connection is closed.
The client establishes a connection with the server and sends the message "Hello, world" encoded as bytes. It then waits for a response from the server and prints the data it receives.


質問 # 27
What is true about the unbind () method? (Select two answers.)

  • A. It is invoked from within a widget's object
  • B. It needs a widget's object as an argument
  • C. It is invoked from within the events object
  • D. It needs the event name as an argument

正解:A、D

解説:
Explanation
Option B is true because the unbind() method is invoked from within a widget's object 1.
Option D is true because the unbind() method needs the event name as an argument 1.
The unbind() 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


質問 # 28
Which sentence about the property decorator is false?

  • A. The property decorator should be defined after the method that is responsible for setting an encapsulated attribute.
  • B. The property decorator should be defined before the methods that are responsible for setting and deleting an encapsulated attribute
  • C. The @property decorator designates a method which is responsible for returning an attribute value
  • D. The property decorator marks the method whose name will be used as the name of the instance attribute

正解:A

解説:
Explanation
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.


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

  • A. It is recommended that you use line breaks after binary operators to improve code readability.
  • B. It is permissible to use line breaks before or after a binary operator as long as the convention is consistent locally However, for new code it is recommended that break lines should be used only after binary operators.
  • C. It is recommended that you use line breaks before binary operators to improve code readability.
  • D. There is no specific PEP 8 recommendation related to using line breaks with binary operators.

正解:C

解説:
Explanation
According to PEP 8, Python's official style guide, line breaks before binary operators produce more readable code, especially in code blocks with long expressions. This is stated in several sources (1,2,6,8) and is a widely accepted convention.
References:
* https://www.python.org/dev/peps/pep-0008/#should-a-line-break-before-or-after-a-binary-operator
* https://stackoverflow.com/questions/30614124/are-long-lines-broken-up-before-or-after-binary-operators-
* https://www.quora.com/What-is-PEP-8-Python
* https://www.techbeamers.com/python-tutorial-pep-8/
* https://www.section.io/engineering-education/python-coding-conventions-guidelines-for-python-programm
* https://towardsdatascience.com/a-step-in-pep8-style-guide-improving-the-readability-of-the-code-8114fd4
* https://www.codementor.io/@rishikeshdhokare/python-coding-style-best-practices-that-every-python-prog
* https://www.dataschool.io/python-pep8-tips-and-tricks/


質問 # 30
......


PCPP1認定は、個人がPythonプログラミングの熟練度を証明するための優れた方法です。これは、Pythonコミュニティ内で高く評価されている世界的に認知された資格です。この認定は、プロフェッショナルなPythonプログラマーになるために必要な基礎知識を個人に提供し、Pythonプログラミングの分野でキャリアを進めるための優れた方法です。

 

最新(2023)Python Institute PCPP-32-101試験問題集:https://www.jpntest.com/shiken/PCPP-32-101-mondaishu

弊社を連絡する

我々は12時間以内ですべてのお問い合わせを答えます。

オンラインサポート時間:( UTC+9 ) 9:00-24:00
月曜日から土曜日まで

サポート:現在連絡