Explanation:
๐น 1️⃣ Tuple Creation
Code:
t = (1, 2, 3)
Explanation:
A tuple named t is created.
It contains three numbers: 1, 2, and 3.
A tuple is immutable, which means its values cannot be changed.
So now:
t = (1, 2, 3)
๐น 2️⃣ For Loop Starts
Code:
for i in t:
Explanation:
The loop runs through each element of the tuple.
Each value is temporarily stored in variable i.
Loop runs 3 times:
Iteration i Value
1st 1
2nd 2
3rd 3
๐น 3️⃣ Adding 5 to Each Element
Code:
i += 5
Explanation:
Adds 5 to i
Same as: i = i + 5
But this only changes the temporary variable i
It does NOT change the tuple
Example:
Original i After i += 5
1 6
2 7
3 8
Tuple remains unchanged.
๐น 4️⃣ Printing the Tuple
Code:
print(t)
Explanation:
Prints the original tuple.
Since tuple was never modified, output will be:
(1, 2, 3)
✅ Final Output
(1, 2, 3)

0 Comments:
Post a Comment