PCEP-30 Output Practice Questions
The free PCEP-30-02: PCEP – Certified Entry-Level Python Programmer questions that deal with output, with answers and explanations. The full bank and the timed practice test cover every topic the exam asks about.
Question #2
What is the expected output of the following code?

Correct answer: C
Explanation
The code snippet that you have sent is trying to print the combined length of two lists, ??collection?? and ??duplicate??. The code is as follows: collection = [] collection.append(1) collection.insert(0, 2) duplicate = collection duplicate.append(3) print(len(collection) + len(duplicate)) The code starts with creating an empty list called ??collection?? and appending the number 1 to it. The list now contains [1]. Then, the code inserts the number 2 at the beginning of the list. The list now contains [2, 1]. Then, the code creates a new list called ??duplicate?? and assigns it the value of ??collection??. However, this does not create a copy of the list, but rather a reference to the same list object. Therefore, any changes made to ??duplicate?? will also affect ??collection??, and vice versa. Then, the code appends the number 3 to ??duplicate??. The list now contains [2, 1, 3], and so does ??collection??. Finally, the code tries to print the sum of the lengths of ??collection?? and ??duplicate??. However, this causes an exception, because the len function expects a single argument, not two. The code does not handle the exception, and therefore outputs nothing. The expected output of the code is nothing, because the code raises an exception and terminates. Therefore, the correct answer is D. The code raises an exception and outputs nothing. Reference: [Python Institute - Entry-Level Python Programmer Certification]
Question #5
How many hashes (+) does the code output to the screen?

Correct answer: D
Explanation
The code snippet that you have sent is a loop that checks if a variable ??floor?? is less than or equal to 0 and prints a string accordingly. The code is as follows: floor = 5 while floor > 0: print(??+??) floor = floor - 1 The code starts with assigning the value 5 to the variable ??floor??. Then, it enters a while loop that repeats as long as the condition ??floor > 0?? is true. Inside the loop, the code prints a ??+?? symbol to the screen, and then subtracts 1 from the value of ??floor??. The loop ends when ??floor?? becomes 0 or negative, and the code exits. The code outputs five ??+?? symbols to the screen, one for each iteration of the loop. Therefore, the correct answer is C. five. Reference: [Python Institute - Entry-Level Python Programmer Certification]
Question #8
What is the expected output of the following code?

Correct answer: B
Explanation
The code snippet that you have sent is using the slicing operation to get parts of a string and concatenate them together. The code is as follows: pizza = ??pizza?? pasta = ??pasta?? folpetti = ??folpetti?? print(pizza[0] + pasta[0] + folpetti[0]) The code starts with assigning the strings ??pizza??, ??pasta??, and ??folpetti?? to the variables pizza, pasta, and folpetti respectively. Then, it uses the print function to display the result of concatenating the first characters of each string. The first character of a string can be accessed by using the index 0 inside square brackets. For example, pizza[0] returns ??p??. The concatenation operation is used to join two or more strings together by using the + operator. For example, ??a?? + ??b?? returns ??ab??. The code prints the result of pizza[0] + pasta[0] + folpetti[0], which is ??p?? + ??p?? + ??f??, which is ??ppt??. The expected output of the code is ppt, because the code prints the first characters of each string. Therefore, the correct answer is B. ppt. Reference: Python String Slicing - W3SchoolsPython String Concatenation - W3Schools
Continue with PCEP-30-02: PCEP – Certified Entry-Level Python Programmer
Unlock the full question bank
You have read the first 10 questions. A subscription opens every question in PCEP-30-02: PCEP – Certified Entry-Level Python Programmer, the full timed practice test, and your progress and weak-topic reporting.
Single exam
$19.99for 30 days
Full question bank and practice test for one exam, for 30 days.
Single exam
$49.99for 1 year
One exam for a full year. Nothing renews and nothing to cancel.
Full access
$39.99/mo
Every exam in the catalogue, month to month.
Full access
$199.99/yr
Every exam in the catalogue for a year.
Already subscribed? Sign in to pick up where you left off.
All PCEP-30-02: PCEP – Certified Entry-Level Python Programmer practice questions →
