Test Index
Python Revision Tour
© examsnet.com
Question : 63 of 102
Marks:
+1,
-0
Write the output displayed on execution of the following Python code :
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 = "#")[CBSE 2024 Set 4]
Solution:
Output:
HIMALAYA#8ALPS#4Explanation:Lengths: HIMALAYA = 8, NILGIRI = 7, ALASKA = 6, ALPS = 4.Only lengths divisible by 4 are stored, so
D = {'HIMALAYA': 8, 'ALPS': 4}.The second loop prints each key and its value separated by # (sep="#"), one pair per line.© examsnet.com
Go to Question: