# PCEP-30-02 — Question 604

**Type:** multiple_choice
**Topics:** topic_1

## Question

What is the output of the following snippet?
//IMG//

## Correct Answer

_See scenario._

## Explanation

Selected Answer: A
Let's analyze this code step by step:

A dictionary is created with key-value pairs:
'one': 'two'
'three': 'one'
'two': 'three'
v is initially set to dictionary['one'], which is 'two'.
The for loop runs for range(len(dictionary)), which is range(3) since the dictionary has 3 key-value pairs.
Inside the loop, v = dictionary[v] is executed 3 times:

First iteration: v = dictionary['two'] = 'three'
Second iteration: v = dictionary['three'] = 'one'
Third iteration: v = dictionary['one'] = 'two'


After the loop, the final value of v is 'two'.
print(v) outputs this final value.

Therefore, the output of this code will be:
two

**Reference:** examtopics_top_comment

---
Source: https://hiexam.net/q/python-institute/PCEP-30-02/604  
Practice (tracked): https://hiexam.net/study/PCEP-30-02/practice