[2023年07月] 最新のPython Institute PCPP-32-101認定練習テスト問題 [Q14-Q36]

Share

[2023年07月] 最新のPython Institute PCPP-32-101認定練習テスト問題

確認済みPCPP-32-101問題集と解答で一年間無料最速更新


PCPP1認定は、世界的に認められ、業界の雇用主から高い評価を受けています。Pythonプログラミングの知識とスキルを実証し、競争の激しい求職市場で差別化するための優れた方法です。さまざまな産業でPythonプログラマの需要が高まる中、PCPP1認定を取得することで、個人に広範なキャリア機会を提供し、彼らの職業上の目標を達成するのに役立ちます。


PCPP1認定プログラムは、Pythonプログラミングでキャリアをスタートしたい人や、既存のスキルを向上させたい人に適しています。この認定プログラムは、雇用主に広く認知されており、競争の激しい就職市場での差別化に役立ちます。さらに、PCPP1認定プログラムは、高度なPython認定に進みたい人にとって堅固な基盤を提供します。


Python InstituteのPCPP-32-101: PCPP1 – Certified Professional in Python Programming 1は、Pythonプログラミングの分野で個人の熟練度をテストするために設計された認定プログラムです。この認定は、Pythonプログラミング言語の成長と発展を促進する非営利団体であるPython Instituteによって提供されています。

 

質問 # 14
What is a static method?

  • A. A method decorated with the @method trait
  • B. A method that requires no parameters referring to the class itself
  • C. A method that works on the class itself
  • D. A method that works on class objects that are instantiated

正解:B

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


質問 # 15
Which of the following values can be returnedby the messagebox. askquestion () method?

  • A. "accept:" and "cancel''
  • B. True and False
  • C. l and o
  • D. "yes" and "no"

正解:D

解説:
Explanation
The messagebox.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 something 1.


質問 # 16
What is true about the invocation of the cget () method?

  • A. It can be replaced with a dictionary-like access manner.
  • B. It can be used to read widget attributes.
  • C. It has the same effect as the config () method.
  • D. It can be used to set new values to widget attributes.

正解:B

解説:
Explanation
The cget() method in Python is used to read the configuration options of a widget in Tkinter. It retrieves the value of a specified configuration option for a Tkinter widget. Hence, option A is the correct answer.


質問 # 17
What will happen if the mamwindow is too small to fit all its widgets?

  • A. The widgets will be scaled down to fit the window's size.
  • B. An exception will be raised.
  • C. The window will be expanded.
  • D. Some widgets may be invisible

正解:D

解説:
Explanation
If the main window is too small to fit all its widgets, some widgets may be invisible. So, the correct answer is Option A.
When a window is not large enough to display all of its content, some widgets may be partially or completely hidden. The window will not automatically expand to fit all of its content, and no exception will be raised. The widgets will not be automatically scaled down to fit the window's size.
If the main window is too small to fit all its widgets, some of the widgets may not be visible or may be partially visible. This is because the main window has a fixed size, and if there are more widgets than can fit within that size, some of them will be outside the visible area of the window.
To avoid this issue, you can use layout managers such as grid, pack, or place to dynamically adjust the size and position of the widgets as the window changes size. This will ensure that all the widgets remain visible and properly arranged regardless of the size of the main window.
References:
* https://www.tkdocs.com/tutorial/widgets.html#managers
* https://www.geeksforgeeks.org/python-tkinter-widgets/
* https://anzeljg.github.io/rin2/book2/2405/docs/tkinter/introduction.html


質問 # 18
Which of the following methods allow you to load a configuration using ConfigParser? (Select two answers.)

  • A. read_conf
  • B. read_dict
  • C. read_str
  • D. read

正解:C、D

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


質問 # 19
Select the true statements about sockets. (Select two answers)

  • A. A socket is always the secure means by which computers on a network can safely communicate, without the risk of exposure to an attack
  • B. A socket is a connection point that enables a one-way communication only between remote processes
  • C. A socket is a connection point that enables a two-way communication between programs running in a network.
  • D. A socket can be used to establish a communication endpoint for processes running on the same or different machines.

正解:C、D

解説:
Explanation
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.
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.
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.
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.
References:
1: https://en.wikipedia.org/wiki/Network_socket 2:
https://www.geeksforgeeks.org/socket-in-computer-network/ 3:
https://www.tutorialspoint.com/what-is-a-network-socket-computer-networks


質問 # 20
Select the true statements about the sqlite3 module. (Select two answers.)

  • A. The execute method allows you to perform several queries at once
  • B. The fetchalt method returns None when no rows are available
  • C. The execute method is provided by the Cursor class
  • D. The fetchone method returns None when no rows are available

正解:C、D

解説:
Explanation
The execute method is provided by the Cursor class
This statement is true because the execute method is one of the methods of the Cursor class in the sqlite3 module. The Cursor class represents an object that can execute SQL statements and fetch results from a database connection. The execute method takes an SQL query as an argument and executes it against the database. For example, cur = conn.cursor (); cur.execute ("SELECT * FROM table") creates and executes a cursor object that selects all rows from a table.
The fetchone method returns None when no rows are available
This statement is true because the fetchone method is another method of the Cursor class in the sqlite3 module.
The fetchone method fetches the next row of a query result set and returns it as a single tuple or None if no more rows are available. For example, row = cur.fetchone () fetches and returns one row from the cursor object or None if there are no more rows.


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

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

正解:A

解説:
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
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. A special method delivered by the traceback module to retrieve a full list of strings describing thetraceback
  • C. An attribute that is added to every object when the traceback module is imported
  • D. An attribute owned by every exception object

正解:A、D

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


質問 # 23
Select the true statement about composition

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

正解:D

解説:
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
Select the true statement about the socket. gaierror exception.

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

正解:A

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


質問 # 25
Select the true statements related to PEP 8 naming conventions. (Select two answers.)

  • A. You should always use self as the first argument to instance methods, and cls as the first argument to class methods.
  • B. Modules should have short names written in CameICase.
  • C. Constants should be written in all lower-case letters with words separated by underscores
  • D. Function and variable names should be lower-case with words separated by underscores.

正解:C、D

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


質問 # 26
If w is a correctly created main application window, which method would you use to foe both of the main window's dimensions?

  • A. w. f ixshape ()
  • B. w.makewindow ()
  • C. w. resizable ()
  • D. w. f ixdim ()

正解:C

解説:
Explanation
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:
importtkinter as tk
root = tk.Tk()
root.geometry("500x400")
root.resizable(False, False)
root.mainloop()
References:
* Tkinter documentation: https://docs.python.org/3/library/tk.html
* Tkinter tutorial: https://www.python-course.eu/python_tkinter.php
The resizable () method of a tkinter window object allows you to specify whether the window can be resized by the user in the horizontal and vertical directions. You can pass two boolean arguments to this method, such as w.resizable (False, False), to prevent both dimensions from being changed. Alternatively, you can pass 0 or
1 as arguments, such as w.resizable (0, 0), to achieve the same effect1.
References:
1: https://stackoverflow.com/questions/36575890/how-to-set-a-tkinter-window-to-a-constant-size Other methods that can be used to control the window size are:
* w.geometry () : This method allows you to set the initial size and position of the window by passing a string argument in the format "widthxheight+x+y", such as w.geometry ("500x500+100+100")12.
* w.minsize () and w.maxsize (): These methods allow you to set the minimum and maximum size of the window in pixels, such as w.minsize (500, 500) and w.maxsize (1000, 1000)12.
* w.pack_propagate () and w.grid_propagate (): These methods allow you to enable or disable the propagation of the size of the widgets inside the window to the window itself. By default, these methods are set to True, which means that the window will adjust its size according to the widgets it contains.
You can set these methods to False or 0 to prevent this behavior, such as w.pack_propagate (0) or w.grid_propagate (0).
* w.place (): This method allows you to place the window at a specific position and size relative to its parent window or screen. You can use keyword arguments such as x, y, width, height, relx, rely, relwidth, and relheight to specify the coordinates and dimensions of the window in absolute or relative terms, such as w.place (x=0, y=0, relwidth=1, relheight=1).
References:
2: https://stackoverflow.com/questions/25690423/set-window-dimensions-in-tkinter-python-3 :
https://stackoverflow.com/questions/36575890/how-to-set-a-tkinter-window-to-a-constant-size/36576068#36576
https://www.skotechlearn.com/2020/06/tkinter-window-position-size-center-screen-in-python.html


質問 # 27
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 A
  • B. Option D
  • C. Option C
  • D. Option B

正解:D


質問 # 28
Analyze the following snippet and select the statement that best describes it.

  • A. The code is an example of implicitly chained exceptions.
  • B. The code is an example of explicitly chained exceptions.
  • C. The code is erroneous as the OwnMath class does not inherit from any Exception type class
  • D. The code is fine and the script execution is not interrupted by any exception.

正解:B

解説:
Explanation
In the given code snippet, an instance of OwnMath exception is raised with an explicitly specified __cause__ attribute that refers to the original exception (ZeroDivisionError). This is an example of explicitly chaining exceptions in Python.


質問 # 29
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. svQUOTE_ALL
  • B. csv.QUOTE_NONE
  • C. csv.QUOTE_MINIMAL
  • D. csv.QUOTE_NONNUMERIC

正解:C

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


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

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

正解:D

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


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

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

正解:B、C

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


質問 # 32
......

最新の2023年最新の実際に出ると確認されたPCPP-32-101問題集で100%無料PCPP-32-101試験問題集:https://www.jpntest.com/shiken/PCPP-32-101-mondaishu

弊社を連絡する

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

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

サポート:現在連絡