Computer Science

a, b, c, d, e = (p, q, r, s, t) = t1

What will be the values and types of variables a, b, c, d, e, p, q, r, s, t if t1 contains (1, 2.0, 3, 4.0, 5) ?

Python Tuples

7 Likes

Answer

VariableValueType
a1int
b2.0float
c3int
d4.0float
e5int
p1int
q2.0float
r3int
s4.0float
t5int
Explanation

The statement unpacks the tuple t1 into the two variable lists given on the left of t1. The list of variables may or may not be enclosed in parenthesis. Both are valid syntax for tuple unpacking. t1 is unpacked into each of the variable lists a, b, c, d, e and p, q, r, s, t. The corresponding variables of the two lists will have the same value that is equal to the corresponding element of the tuple.

Answered By

2 Likes


Related Questions