Register Now

Login

Lost Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Is the following Python code valid?
>>> a=(1,2,3)
>>> b=(‘A’,’B’,’C’)
>>> c=tuple(zip(a,b))

Is the following Python code valid?
>>> a=(1,2,3)
>>> b=(‘A’,’B’,’C’)
>>> c=tuple(zip(a,b))
a) Yes, c will be ((1, ‘A’), (2, ‘B’), (3, ‘C’))
b) Yes, c will be ((1,2,3),(‘A’,’B’,’C’))
c) No because tuples are immutable
d) No because the syntax for zip function isn’t valid

Answer: a
Explanation: Zip function combines individual elements of two iterables into tuples. Execute in Python shell to verify.

Join The Discussion