Culture Hard

What happens when you run this code?

from __future__ import braces
  • Python starts allowing { } blocks instead of indentation.

  • It silently does nothing.

  • It raises SyntaxError: not a chance.

  • It raises ImportError: no module named braces.

Answer

This Easter egg answers the perennial request to replace indentation with curly braces. Attempting it raises SyntaxError: not a chance.

How is the Zen of Python text stored inside the this module?

  • As plain text.

  • Base64 encoded.

  • ROT13 encoded.

  • Compressed with gzip.

Answer

Fittingly obfuscated, the Zen text in this.py is stored ROT13 encoded and decoded at import time using a small character-translation dictionary.

Which earlier language, which Guido helped develop at CWI, strongly influenced Python?

  • Pascal.

  • Modula-3.

  • ABC.

  • Smalltalk.

Answer

Python was heavily influenced by ABC, a teaching language Guido had worked on at CWI. He kept ABC's readability while fixing what he saw as its shortcomings.

In which country did Guido van Rossum begin developing Python at CWI?

  • The United States.

  • Germany.

  • Belgium.

  • The Netherlands.

Answer

Guido started Python at CWI, the national research institute for mathematics and computer science in the Netherlands. The Zen even winks at this with "unless you're Dutch".

What is the final aphorism of the Zen of Python?

  • "Readability counts."

  • "Namespaces are one honking great idea -- let's do more of those!"

  • "Now is better than never."

  • "Simple is better than complex."

Answer

The Zen closes on an upbeat note: "Namespaces are one honking great idea -- let's do more of those!"

Which special ("dunder") method implements the < operator?

  • __less__

  • __lt__

  • __cmp__

  • __min__

Answer

Python calls __lt__ (short for "less than") to evaluate the < operator between two objects.

Which statement about CPython's GIL is true?

  • It lets any number of threads run Python bytecode simultaneously.

  • It is a feature of every Python implementation, including Jython.

  • It allows only one thread to execute Python bytecode at a time.

  • It only affects programs that use asyncio.

Answer

The Global Interpreter Lock permits just one thread to run Python bytecode at a time in CPython. Implementations like Jython have no GIL.

Which Python release first introduced f-strings?

  • Python 3.4.

  • Python 3.5.

  • Python 3.6.

  • Python 3.8.

Answer

Formatted string literals (f-strings), specified in PEP 498, arrived in Python 3.6.

Which Python release introduced the walrus operator (:=)?

  • Python 3.5.

  • Python 3.6.

  • Python 3.7.

  • Python 3.8.

Answer

The walrus operator from PEP 572 shipped in Python 3.8.

In which Python release did PEP 484 type hints first become available?

  • Python 3.4.

  • Python 3.5.

  • Python 3.6.

  • Python 3.7.

Answer

PEP 484 and the typing module landed in Python 3.5, giving Python a standard syntax for type annotations.

What was the standard tool for migrating Python 2 code to Python 3?

  • pyupgrade

  • py23

  • 2to3

  • modernize

Answer

2to3 was the tool shipped with Python that automatically rewrote many Python 2 constructs into their Python 3 equivalents.

Which of these is a real feature you can enable with from __future__ import?

  • goto

  • switch

  • annotations

  • macros

Answer

from __future__ import annotations (PEP 563) makes annotations be stored as strings rather than evaluated at definition time. The others are not __future__ features.

The debate over which feature is often cited as a factor in Guido stepping down as BDFL?

  • f-strings.

  • Type hints.

  • The walrus operator (PEP 572).

  • Async/await.

Answer

The contentious debate around PEP 572's walrus operator is widely cited as part of what led Guido to step down as BDFL in 2018.

After Guido stepped down, how is Python's language governance now organized?

  • A single successor BDFL was appointed.

  • An elected Steering Council.

  • A public shareholder vote.

  • The decision was handed to the PyPI maintainers.

Answer

Since 2019 the language has been governed by an elected Steering Council (PEP 13) rather than a single benevolent dictator.

The Easter egg from __future__ import barry_as_FLUFL re-enables which old operator?

from __future__ import barry_as_FLUFL
print(1 <> 2)
  • The backtick repr operator.

  • The print statement.

  • The <> "not equal" operator.

  • Integer division with /.

Answer

This joke (PEP 401) honors Barry Warsaw as the "Friendly Language Uncle For Life" by temporarily bringing back Python 2's <> not-equal operator, so 1 <> 2 evaluates to True.

Which pair of names, alongside Guido van Rossum, are listed as authors of PEP 8?

  • Tim Peters and Raymond Hettinger.

  • Barry Warsaw and Nick Coghlan.

  • Brett Cannon and Alex Martelli.

  • Kenneth Reitz and David Beazley.

Answer

PEP 8, the style guide, is credited to Guido van Rossum, Barry Warsaw, and Nick Coghlan.

In the Monty Python "Spam" sketch that inspired Python's placeholder names, where is it set?

  • A pet shop.

  • A café where nearly every menu item contains spam.

  • A courtroom.

  • A cheese shop.

Answer

The sketch takes place in a café whose menu is overrun with spam, which is why spam (and eggs) became Python's go-to example names.

Which value does the Zen of Python associate specifically with "you're Dutch"?

  • "Errors should never pass silently."

  • "Readability counts."

  • "There should be one obvious way to do it."

  • "Now is better than never."

Answer

The Zen follows "There should be one-- and preferably only one --obvious way to do it." with the wink "Although that way may not be obvious at first unless you're Dutch." -- a nod to Guido's nationality.

At which company did Guido van Rossum work from 2005 to 2012?

  • Microsoft.

  • Dropbox.

  • Google.

  • Red Hat.

Answer

Guido van Rossum worked at Google from 2005 to 2012 (where he spent part of his time on Python), then at Dropbox until 2019, and later joined Microsoft in 2020.

Which experimental CPython build, added in Python 3.13, can run without the GIL?

  • The "stackless" build.

  • The "free-threaded" (no-GIL) build.

  • The "async" build.

  • The "JIT-only" build.

Answer

PEP 703 introduced an experimental free-threaded build of CPython in Python 3.13 that can run without the Global Interpreter Lock, allowing true parallelism across threads.