GoShiken PCPP-32-101問題集46問でPython Institute PCPPを確実実践 [Q11-Q28]

Share

GoShiken PCPP-32-101問題集46問でPython Institute PCPPを確実実践

リアル最新PCPP-32-101試験問題PCPP-32-101問題集


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


Python InstituteのPCPP-32-101(PCPP1)試験は、Pythonプログラミングの専門知識を証明したい個人を対象とした認定プログラムです。この試験では、候補者のPythonコードの記述と保守能力、およびプログラミング言語の特徴と構文に関する知識が評価されます。データ型、制御構造、関数、モジュール、オブジェクト指向プログラミングの概念など、幅広いトピックをカバーしています。

 

質問 # 11
Which function or operator should you use to obtain the answer True or False to the question: "Do two variables refer to the same object?"

  • A. The = operator
  • B. The isinstanceO function
  • C. The is operator
  • D. The id () function

正解:C

解説:
Explanation
To test whether two variables refer to the same object in memory, you should use the is operator.
The is operator returns True if the two variables point to the same object in memory, and False otherwise.
For example:
a = [1, 2, 3]
b = a
c = [1, 2, 3]
print(a is b) # True
print(a is c) # False
In this example, a and b refer to the same list object in memory, so a is b returns True. On the other hand, a and c refer to two separate list objects with the same values, so a is c returns False.


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

正解:A


質問 # 13
Which of the following will set the button text's font to 12 point italics Anal? (Select two answers)

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

正解:A、C

解説:
Explanation
Option B is correct because it sets the font option of the button to a tuple containing the font family ('Arial'), size (12), and style ('italic').
Option C is correct because it sets the font option of the button to a string containing the font family ('Arial'), size (12), and style ('italic') separated by spaces.


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

  • A. It is parameterless
  • B. It causes all the widgets to disappear
  • C. It can be invoked from the main window widget only
  • D. It can be invoked from any widget

正解:A、D

解説:
Explanation
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.
References:
* Tkinter documentation: https://docs.python.org/3/library/tkinter.html#event-bindings
* Tkinter tutorial: https://www.python-course.eu/tkinter_events_binds.php


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

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

正解:C、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


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

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

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


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

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


質問 # 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 a decorator that can trigger an infinite recursion.
  • C. It is an example of decorator stacking.
  • D. The function is erroneous.

正解: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
Select the true statement related to PEP 257.

  • A. String literals that occur immediately after a simple assignment at the top level of a module are called complementary docstrings
  • B. String Iiterals that occur in places other than the first statement in a module, function, or class definition can act as documentation They are recognized by the Python bytecode compiler and are accessible as runtime object attributes
  • C. String literals that occur immediately after another docstring are called attribute docstrings.
  • D. Attribute docstrings and Additional docstrings are two types of extra docstrings that can be extracted by software tools.

正解:D

解説:
Explanation
The true statement related to PEP 257 is Option B. According to PEP 257, string literals occurring elsewhere in Python code may also act as documentation. They are not recognized by the Python bytecode compiler and are not accessible as runtime object attributes (i.e. not assigned to doc), but two types of extra docstrings may be extracted by software tools: String literals occurring immediately after a simple assignment at the top level of a module, class, or init method are called "attribute docstrings". String literals occurring immediately after another docstring are called "additional docstrings"1.


質問 # 20
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 timeout occurs on a socket.
  • C. It is raised when a system function returns a system-related error.
  • D. It is raised when an address-related error caused by the repr () function occurs.

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


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

What is the result of the following code?

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

正解:A

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


質問 # 22
Select the true statement about composition

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

正解:C

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


質問 # 23
Look at the following code snippets and decide which ones follow PEP 8 recommendations for whitespacesin expressions and statements(Select two answers.)

  • A. A whitespace immediately after the opening parenthesis that starts indexing or slicing:
  • B. No whitespace immediately before the opening parenthesis that starts the list of arguments of a function call:
  • C. A whitespace immediately before a comma,semicolon, and colon:
  • D. No whitespace between a trailing comma and a following closing parenthesis:

正解:B、D

解説:
Explanation
Option A is true because PEP 8 recommends avoiding extraneous whitespace immediately inside parentheses, brackets or braces 1.
Option C is true because PEP 8 recommends avoiding extraneous whitespace between a trailing comma and a following close parenthesis 1.


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

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

正解:A、D


質問 # 25
What does the term deserialization mean? Select the best answer.

  • A. It is a process of converting the structure of an object into a stream of bytes
  • B. It is another name for the data transmission process
  • C. It is a process of assigning unique identifiers to every newly created Python object
  • D. It is a process of creating Python objects based on sequences of bytes.

正解:D

解説:
Explanation
answer A. Deserialization is the process of converting data that has been serialized or encoded in a specific format, back into its original form as an object or a data structure in memory. In Python, this typically involves creating Python objects based on sequences of bytes that have been serialized using a protocol such as JSON, Pickle, or YAML.
For example, if you have a Python object my_obj and you want to serialize it to a JSON string, you might do something like this:
importjson
serialized_obj = json.dumps(my_obj)
To deserialize the JSON string back into a Python object, you would use the json.loads() method:
deserialized_obj = json.loads(serialized_obj)
This would convert the JSON string back into its original Python object form.


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

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

正解:C

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


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

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

正解:A、C

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


質問 # 28
......


PCPP1試験は、基本的なデータ型、制御構造、関数、モジュール、エラーハンドリングを含む、さまざまなトピックをカバーしています。さらに、候補者は、Pythonコードの書き方とデバッグの能力、およびオブジェクト指向プログラミングの概念の理解についてもテストされます。

 

PCPP-32-101別格な問題集で最上級の成績にさせるPCPP-32-101問題:https://www.goshiken.com/Python-Institute/PCPP-32-101-mondaishu.html