Question:medium

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='#')

Show Hint

By default, iterating over a dictionary yields its keys.
Use D.values() to get values and D.items() to get key-value pairs.
Updated On: Jan 14, 2026
  • S01#S02#
  • 95#96#
  • S01,95#S02,96#
  • S01#95#S02#96#
Show Solution

The Correct Option is A

Solution and Explanation

A dictionary D is established with keys `'S01'` and `'S02'` and corresponding values 95 and 96.
The for loop iterates through D.
When iterating over a dictionary in Python using a for loop, the default behavior is to iterate over its keys.
Consequently, I will first assume the value `'S01'`, followed by `'S02'.
Within the loop, the print() function displays the current key, appending a `#` character without advancing to a new line.
Thus, the resulting output will be `S01#S02#`.
The values 95 and 96 will not be displayed as the loop only accesses the keys.
Therefore, option (A) is the correct selection.
Was this answer helpful?
0