Computer Science
Find the output generated by following code fragments :
(a, b, c) = (1, 2, 3)
Python Tuples
2 Likes
Answer
Output
a = 1
b = 2
c = 3
Explanation
When we put tuples on both sides of an assignment operator, a tuple unpacking operation takes place. The values on the right are assigned to the variables on the left according to their relative position in each tuple. As you can see in the above example, a will be 1, b will be 2, and c will be 3.
Answered By
1 Like
Related Questions
How are in operator and index( ) similar or different ?
Find the output generated by following code fragments :
plane = ("Passengers", "Luggage") plane[1] = "Snakes"
Find the output generated by following code fragments :
(a, b, c, d) = (1, 2, 3)
Find the output generated by following code fragments :
a, b, c, d = (1, 2, 3)