OA. free
Free
Micron Core Computer Science Core Computer Science Medium

What would the following code yield?

Micron technical mcq question, verified with a worked answer. Free to practise - no sign-up.

What would the following code yield?**

repo = 'abcdefghi|jkl123'
print repo[:4] + repo[4:]
Choose one option.
Show answer & explanation
Answer: B. abcdefghi|jkl123

The code slices the string repo at index 4 and concatenates the two parts back together. repo[:4] returns characters 0–3 ('abcd'), and repo[4:] returns everything from index 4 onward ('efghi|jkl123'). When concatenated, this reconstructs the original string.

Step-by-step Derivation:
String indexing in Python is zero-based.
repo = 'abcdefghi|jkl123'
Indices: 0:'a', 1:'b', 2:'c', 3:'d', 4:'e', 5:'f', ...
repo[:4] selects indices 0, 1, 2, 3 → 'abcd'
repo[4:] selects indices 4 to end → 'efghi|jkl123'
repo[:4] + repo[4:] = 'abcd' + 'efghi|jkl123' = 'abcdefghi|jkl123'
Result: abcdefghi|jkl123