Question

1.
2.
3.
4.
Answer (Detailed Solution Below)

Option 4 : 4 2 1

Advertisement

Detailed Solution

सही उत्तर 4 2 1 है।

Key Points
Helpful?
PrepSnapprepsnap.in • Part -A

Question:

What does the following Python dictionary-counting code output? / शब्दकोश गिनती वाले निम्नलिखित Python कोड का आउटपुट क्या है? d = {} for ch in 'mississippi': d[ch] = d.get(ch, 0) + 1 print(d['s'], d['p'], d['m'])

1.
4 4 1
2.
2 4 1
3.
4 2 2
4.
4 2 1

Correct Answer: 4 2 1

'mississippi' contains s four times, p twice and m once, so the counts print as 4 2 1. / 'mississippi' में s चार बार, p दो बार और m एक बार है, अतः गिनती 4 2 1 छपती है।

Downloaded from PrepSnap (prepsnap.in)