CBSE · 083Class XII · 2025Section C3 marks

Question 31(or)

4 March 2025 · Computer Science (083)

Write the output on execution of the following Python code:

python
def Change(X):
    for K,V in X.items():
        L1.append(K)
        L2.append(V)
D={1:"ONE",2:"TWO",3:"THREE"}
L1=[]
L2=[]
Change(D)
print(L1)
print(L2)
print(D)

Answer

[1, 2, 3] ['ONE', 'TWO', 'THREE'] {1: 'ONE', 2: 'TWO', 3: 'THREE'}

Explanation

Iterates dictionary items, separates keys to L1 and values to L2. Prints L1, L2, then original Dict.