Test Index

Python Revision Tour Get it on Google PlayDownload on the App Store CBSE Board Videos

© examsnet.com
Question : 35 of 102
Marks: +1, -0
Consider the statements given below and then choose the correct output from the given options :
D={'S01':95, 'S02':96 }
for I in D :
print(I,end='#')
[CBSE 2025 Set 4]
Solution:  
Concept:
A for loop over a dictionary goes through its keys (in insertion order).
Explanation:
I takes the values 'S01' and then 'S02'; each is printed followed by '#' instead of a new line.
S01#S02#
Key point: To get the values use D.values() or D[I]; to get both use D.items().
Answer:
Option A (S01#S02#)
© examsnet.com
Advertisements
Go to Question: