Post

@PythonPr Answer: B) -5
Step by step:
› Start: a=10, b=5
› a, b = b, a swaps them → a=5, b=10
› print(a - b) → 5 - 10 = -5
For beginners: This is Python's elegant way to swap! No temp variable needed. Technically, the tuple (b, a) gets unpacked into variables a, b in order.
English

@PythonPr The correct answer is B) -5.
This code demonstrates Python's elegant way of swapping variables using tuple unpacking.
Understand:
Initialization: a is 10, b is 5.
The Swap (a, b = b, a):
Python evaluates the right side first, creating a temporary tuple (5, 10).
English

@PythonPr The "magic" line secret is :
a, b = b, a -> means: "new a = old b" and "new b = old a". Swap the variables and that called <tupple unpacking>
English

@PythonPr Ans-->B) -5
Key concept
Python evaluates the right-hand side first, creates a tuple (b, a), and then assigns it to (a, b) that’s why swapping works without a temp variable.
English

@PythonPr Answer: B) -5
Because a, b = b, a swaps the values in one line (tuple unpacking).
So after swap: a = 5, b = 10 → print(a - b) = 5 - 10 = -5
English

@PythonPr B: -5
as the variables are interchanged on the third line.
English

@PythonPr B. -5
a = 5 and b = 10 after swapping the values, so a-b = 5-10, which is equal to -5
English

@PythonPr Answer B) is the ✅️
Here we are using the concept of swap of two numbers, and a = 5 and b = 10 print(5-10) = -5 Answer.
English

@PythonPr The classic Python swap! 🐍 Most languages need a third 'temp' variable, but Python handles this with tuple packing and unpacking in one line
English
























