exam questions

Exam PCEP-30-02 All Questions

View all questions & answers for the PCEP-30-02 exam

Exam PCEP-30-02 topic 1 question 24 discussion

Actual exam question from Python Institute's PCEP-30-02
Question #: 24
Topic #: 1
[All PCEP-30-02 Questions]

What is the expected output of the following code?

  • A. three
  • B. ('one', 'two', 'three')
  • C. two
  • D. one
Show Suggested Answer Hide Answer
Suggested Answer: D 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
hovnival
1 month, 2 weeks ago
Selected Answer: D
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
upvoted 2 times
...
christostz03
5 months, 2 weeks ago
d is correct answer
upvoted 1 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago