PCEP-30-02 Python Institute試験の準備方法|素晴らしいPCEP-30-02テスト内容試験|更新するPCEP - Certified Entry-Level Python Programmer赤本勉強GoShikenのPython InstituteのPCEP-30-02試験トレーニング資料はIT認証試験を受ける人々の必需品です。このトレーニング資料を持っていたら、試験のために充分の準備をすることができます。そうしたら、試験に受かる信心も持つようになります。GoShikenのPython InstituteのPCEP-30-02試験トレーニング資料は特別に受験生を対象として研究されたものです。インターネットでこんな高品質の資料を提供するサイトはGoShikenしかないです。 Python Institute PCEP - Certified Entry-Level Python Programmer 認定 PCEP-30-02 試験問題 (Q31-Q36):質問 # 31
Assuming that the phone_dir dictionary contains name:number pairs, arrange the code boxes to create a valid line of code which adds Oliver Twist's phone number (5551122333) to the directory. 正解:
解説:
phone_dir["Oliver Twist"] = ["5551122333"]
Explanation:
To correctly add Oliver Twist's phone number to the phone_dir dictionary, the code must follow this phone_dir["Oliver Twist"] = ["5551122333"] Now, let's match that with your code boxes and arrange them:
* phone_dir
* [
* "Oliver Twist"
* ]
* =
* [
* "5551122333"
* ]
Final Order:phone_dir # [ # "Oliver Twist" # ] # = # [ # "5551122333" # ]
質問 # 32
Insert the code boxes in the correct positions in order to build a line of code which asks the user for an Integer value and assigns it to the depth variable.
(Note: some code boxes will not be used.) 正解:
解説:
質問 # 33
What is the expected output of the following code?
A. 0
B. 1
C. 2
D. 3
正解:C
解説:
The code snippet that you have sent is using the count method to count the number of occurrences of a value in a list. The code is as follows:
my_list = [1, 2, 3, 4, 5] print(my_list.count(1))
The code starts with creating a list called "my_list" that contains the numbers 1, 2, 3, 4, and 5. Then, it uses the print function to display the result of calling the count method on the list with the argument 1. The count method is used to return the number of times a value appears in a list. For example, my_list.count(1) returns
1, because 1 appears once in the list.
The expected output of the code is 1, because the code prints the number of occurrences of 1 in the list.
Therefore, the correct answer is D. 1.
Reference: Python List count() Method - W3Schools
質問 # 34
What is true about tuples? (Select two answers.)
A. The len { } function cannot be applied to tuples.
B. An empty tuple is written as { } .
C. Tuples are immutable, which means that their contents cannot be changed during their lifetime.
D. Tuples can be indexed and sliced like lists.
正解:C、D
解説:
Tuples are one of the built-in data types in Python that are used to store collections of data. Tuples have some characteristics that distinguish them from other data types, such as lists, sets, and dictionaries. Some of these characteristics are:
* Tuples are immutable, which means that their contents cannot be changed during their lifetime. Once a tuple is created, it cannot be modified, added, or removed. This makes tuples more stable and reliable than mutable data types. However, this also means that tuples are less flexible and dynamic than mutable data types. For example, if you want to change an element in a tuple, you have to create a new tuple with the modified element and assign it to the same variable12
* Tuples are ordered, which means that the items in a tuple have a defined order and can be accessed by using their index. The index of a tuple starts from 0 for the first item and goes up to the length of the tuple minus one for the last item. The index can also be negative, in which case it counts from the end of the tuple. For example, if you have a tuple t = ("a", "b", "c"), then t[0] returns "a", and t
[-1] returns "c"12
* Tuples can be indexed and sliced like lists, which means that you can get a single item or a sublist of a tuple by using square brackets and specifying the start and end index. For example, if you have a tuple t
= ("a", "b", "c", "d", "e"), then t[2] returns "c", and t[1:4] returns ("b", "c", "d"). Slicing does not raise any exception, even if the start or end index is out of range. It will just return an empty tuple or the closest possible sublist12
* Tuples can contain any data type, such as strings, numbers, booleans, lists, sets, dictionaries, or even other tuples. Tuples can also have duplicate values, which means that the same item can appear more than once in a tuple. For example, you can have a tuple t = (1, 2, 3, 1, 2), which contains two 1s and two
2s12
* Tuples are written with round brackets, which means that you have to enclose the items in a tuple with parentheses. For example, you can create a tuple t = ("a", "b", "c") by using round brackets. However, you can also create a tuple without using round brackets, by just separating the items with commas. For example, you can create the same tuple t = "a", "b", "c" by using commas. This is called tuple packing, and it allows you to assign multiple values to a single variable12
* The len() function can be applied to tuples, which means that you can get the number of items in a tuple by using the len() function. For example, if you have a tuple t = ("a", "b", "c"), then len(t) returns 312
* An empty tuple is written as (), which means that you have to use an empty pair of parentheses to create a tuple with no items. For example, you can create an empty tuple t = () by using empty parentheses.
However, if you want to create a tuple with only one item, you have to add a comma after the item, otherwise Python will not recognize it as a tuple. For example, you can create a tuple with one item t = ("a",) by using a comma12 Therefore, the correct answers are A. Tuples are immutable, which means that their contents cannot be changed during their lifetime. and D. Tuples can be indexed and sliced like lists.
Reference: Python Tuples - W3SchoolsTuples in Python - GeeksforGeeks
質問 # 35
Python Is an example of which programming language category?
A. machine
B. interpreted
C. assembly
D. compiled
正解:B
解説:
Explanation
Python is an interpreted programming language, which means that the source code is translated into executable code by an interpreter at runtime, rather than by a compiler beforehand. Interpreted languages are more flexible and portable than compiled languages, but they are also slower and less efficient. Assembly and machine languages are low-level languages that are directly executed by the hardware, while compiled languages are high-level languages that are translated into machine code by a compiler before execution.