The quiz where the difficulty automagically adapts to the player's Python knowledge
This is a question page. You can use this page to bookmark a question. Start a new quiz!
Question #312
my_tuple = (1, 2, 3)
print(0, 2*my_tuple, 4)
An interesting use-case for the unpacking operator, * , is the ability to merge several iterables into a final sequence. This functionality works for lists, tuples, and sets. Note that we unpack here 2*my_tuple . (stackabuse.com/unpacking-in-python-beyond-parallel-assign...)
What is the output of the code snippet below?
— The Python Quiz (@thepythonquiz) January 18, 2021
my_tuple = (1, 2, 3)
print(0, 2*my_tuple, 4)
0 1 2 3 4
0 (2, 4, 6) 4
0 (1, 2, 3, 1, 2, 3) 4
It will throw an IndexErrorerror.
π Comment the answer, like and retweet! #python
Question difficulty: π΅π΅π΅π΅π΅