Explanation:
๐น Step 1 — "1101"
"1101"
This is a string containing four characters:
1 1 0 1
๐น Step 2 — map(int, "1101")
map(int, "1101")
map() applies int() to each character:
"1" → 1
"1" → 1
"0" → 0
"1" → 1
So the values are:
1, 1, 0, 1
๐น Step 3 — sum()
sum(map(int, "1101"))
Now Python adds them:
1 + 1 + 0 + 1 = 3
So:
sum(...) → 3
๐น Step 4 — % 3
Now the expression becomes:
3 % 3
% is the modulo operator. It gives the remainder after division.
3 ÷ 3 → remainder 0
Therefore:
3 % 3 → 0
๐น Step 5 — print()
Finally:
print(0)
✅ Output
0

0 Comments:
Post a Comment