Visitar URL original
Quiz yourself on Python 3.15's new features - Python Morsels

This quiz has changed since you started it, so your earlier answers can’t be picked back up. Begin to take the current version.

Python Morsels quiz

Average 6/14 · 18 takes

Quiz yourself on Python 3.15's new features

Python 3.15's new built-in types, a new way to delay imports, new comprehension syntax, new tools for finding slow code, and smaller standard library changes.

What to expect

  • 14 questions

    One at a time.

  • Answers as you go

    Explained after your answer.

  • No account needed

    Share how you did afterward.

Quiz yourself on Python 3.15's new features right so far
Question of 14 Discard answers and start over?

This function needs a default value that no caller could ever pass, since None is a legitimate value here. Python 3.15 has a new built-in for making that kind of value. Fill in its name:

MISSING = ________("MISSING")

def get_setting(name, default=MISSING):
    ...
✓ Correct × Incorrect % of people got this right
The answer

Which of these are true of the objects that Python 3.15's sentinel() built-in creates?

Pick all that apply. selected
✓ Correct × Incorrect % of people got this right
You missed
Incorrect

Python 3.15 added a soft keyword that defers loading a module until the first time the imported name is used. Fill in the blank:

________ import json

✓ Correct × Incorrect % of people got this right
The answer

Write the import of pi from math that Python won't load until pi is first used.

✓ Correct × Incorrect % of people got this right
Your answer
The answer

Which of these uses of Python 3.15's lazy keyword are allowed?

Pick all that apply. selected
✓ Correct × Incorrect % of people got this right
You missed
Incorrect

Python 3.15's frozendict is an immutable mapping. What does this expression evaluate to?

isinstance(frozendict(retries=3), dict)

Pick one to answer.

✓ Correct × Incorrect % of people got this right

Which of these are true of frozendict({'x': 1, 'y': 2}) in Python 3.15?

Pick all that apply. selected
✓ Correct × Incorrect % of people got this right
You missed
Incorrect

Using Python 3.15's new comprehension syntax, flatten nested into the list [1, 2, 3, 4, 5, 6]:

nested = [[1, 2], [3], [4, 5, 6]]
flat = ________
✓ Correct × Incorrect % of people got this right
The answer

A production Python process is misbehaving, and restarting it isn't an option. Python 3.15 ships a profiler that can profile the running process in place by its process ID, with almost no overhead. Assuming the process ID is 1234, fill in the blank:

python ____________ 1234

✓ Correct × Incorrect % of people got this right
The answer

Python 3.15 reorganized Python's profilers into a new profiling package. Which of these are true?

Pick all that apply. selected
✓ Correct × Incorrect % of people got this right
You missed
Incorrect

Which of these gained colored output by default in Python 3.15?

Pick all that apply. selected
✓ Correct × Incorrect % of people got this right
You missed
Incorrect

For decades, a line beginning with import in a site-packages .pth file could run arbitrary code every time Python launched. Python 3.15 deprecates those lines in favor of a new kind of file that instead lists the functions for Python to call when it launches. What's the new file's extension?

✓ Correct × Incorrect % of people got this right
Your answer
The answer

When output doesn't fit on one line, pprint traditionally aligns the wrapped items with the opening bracket. Python 3.15 added a parameter that switches to the conventional multi-line style you'd get from a code formatter like Black. Fill in the parameter name:

pprint.pp(config, ________=True)

✓ Correct × Incorrect % of people got this right
The answer

What's the preferred alias for re.match() in Python 3.15?

✓ Correct × Incorrect % of people got this right
Your answer
The answer