Certified Entry-Level Python Programmer (PCEP-30-02) — Question 71
What is the expected output of the following code?
menu = {“bunuelo”: 3.21, “torrijas”: 4.99, “churros”: 1.99}
for value in menu.values():
print (str(value) [1], end “”)
Answer options
- A. nru
- B. The code is eeromeous and cannot be run.
- C. 3.214.991.99
- D. …
Correct answer: D
Explanation
The code intends to print the second character of each value in the 'menu' dictionary, but 'end' is incorrectly formatted, leading to an output that depends on the implementation. The correct answer is D, as it indicates the output will be incomplete or represented by an ellipsis, since the specific output cannot be determined due to the error in the print statement. Options A, B, and C don't accurately represent the output of the code.