Explanation:
๐ข 1. Store "10" in x
x = "10"
Here, "10" is a string, not an integer.
x → "10"
๐ก 2. x * 2
x * 2
Since x is a string, * 2 repeats the string.
"10" * 2
becomes:
"1010"
⚠️ It does not mean 10 × 2.
๐ต 3. int(x)
int(x)
The string "10" is converted into the integer 10.
"10" → 10
๐ 4. int(x) // 2
Now Python performs floor division:
10 // 2
Result:
5
๐ฃ 5. str(int(x) // 2)
The result 5 is converted back into a string:
str(5)
Result:
"5"
๐ด 6. String Concatenation
Now the expression becomes:
"1010" + "5"
Because both values are strings, + joins them:
"10105"
⚡ Complete Flow
x = "10"
↓
x * 2
↓
"1010"
int(x) // 2
↓
10 // 2
↓
5
↓
str(5)
↓
"5"
"1010" + "5"
↓
"10105"
✅ Final Output
10105

0 Comments:
Post a Comment