The Python Papers

Share this post

[0006] Python Quiz 2 - Number Explosion

www.pythonpapers.com

[0006] Python Quiz 2 - Number Explosion

Mike Driscoll
Jan 18, 2023
∙ Paid
1
Share this post

[0006] Python Quiz 2 - Number Explosion

www.pythonpapers.com
Share

You will sometimes come across examples of code that use one or two asterisks. Depending on how the asterisks are used, they can mean different things to Python.

Check your understanding of what a single asterisk means in the following quiz!

The Quiz

What will be the output if you run this code?

numbers = range(3)
output = {*numbers}
print(output)

A) {range}

B) (range)

C) [0, 1, 2]

D) (0, 1, 2)

E) {0, 1, 2}

Hint

"Unpacking generalizations" is the term to look up if you get stuck.

The Python Quiz Book

This quiz comes from my latest book, The Python Quiz Book. You should get the book to see the answer to this quiz or one of the 100+ other quizzes! The quiz book will be finished in March 2023. However, you can purchase early access to it on the following websites:

  • Gumroad

  • Leanpub

Or, if you’re a paid subscriber, keep reading to find out the answer to this quiz!

Keep reading with a 7-day free trial

Subscribe to

The Python Papers
to keep reading this post and get 7 days of free access to the full post archives.

Already a paid subscriber? Sign in
© 2023 Mike Driscoll
Privacy ∙ Terms ∙ Collection notice
Start WritingGet the app
Substack is the home for great writing