PCEP-30-02 Exam QuestionsBrowse all questions from this exam

PCEP-30-02 Exam - Question 24


What is the expected output of the following code?

Show Answer
Correct Answer:

Discussion

3 comments
Sign in to comment
hovnivalOption: D
Dec 22, 2024

Let's analyze the code step by step to determine the expected output. Code breakdown: Initialization: data = {'one': 'two', 'two': 'three', 'three': 'one'} res = data['three'] # res = 'one' Loop execution: for _ in range(len(data)): # len(data) = 3 res = data[res] The loop runs 3 times (since len(data) = 3). Iterations: First iteration: res = data[res] = data['one'] = 'two' Second iteration: res = data[res] = data['two'] = 'three' Third iteration: res = data[res] = data['three'] = 'one' Final value of res: After 3 iterations, res is 'one'. Output: print(res) # Outputs 'one' Expected Output: one

christostz03
Aug 20, 2024

d is correct answer

OgtMarcOption: D
Apr 15, 2025

D is The right