CBSE · 083Class XII · 2024Section B2 marks

Question 22

2 April 2024 · Computer Science (083)

Write the output displayed on execution of the following Python code :

python
LS = ["HIMALAYA", "NILGIRI", "ALASKA", "ALPS"]
D = {}
for S in LS:
    if len(S) % 4 == 0:
        D[S] = len(S)
for K in D:
    print(K, D[K], sep="#")

Answer

text
HIMALAYA#8
ALPS#4

Explanation

HIMALAYA has length 8 (8%4==0) and ALPS has length 4 (4%4==0). They are added to the dictionary and printed.