最新的Python Institute PCEP - Certified Entry-Level Python Programmer - PCEP-30-02免費考試真題

問題1
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.)
正確答案:

Explanation:

One possible way to 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 is:
depth = int(input("Enter the immersion depth: "))
This line of code uses the input function to prompt the user for a string value, and then uses the int function to convert that string value into an integer number. The result is then assigned to the variable depth.
You can find more information about the input and int functions in Python in the following references:
* [Python input() Function]
* [Python int() Function]
問題2
What is the expected output of the following code?

正確答案: A
說明:(僅 VCESoft 成員可見)
問題3
What is the expected result of the following code?

正確答案: B
說明:(僅 VCESoft 成員可見)
問題4
Which of the following functions can be invoked with two arguments?

正確答案: A
說明:(僅 VCESoft 成員可見)
問題5
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" # ]