How well do you know Python?

Chris Angelico rosuav at gmail.com
Tue Jul 5 00:02:36 EDT 2016


After some discussion with a Ruby on Rails programmer about where Ruby
ends and where Rails begins (and it's definitely not where I'd have
expected... Rails does a ton of monkey-patching, including of built-in
types, to provide functionality that is strangely absent from the core
language), I tried to come up with some somewhat-challenging Python
questions. But to make them hard, I had to go a smidge more esoteric
than the Ruby questions did.... Anyhow, see how you go. Assume Python
3.x unless stated.

1) Under what circumstances can str.upper() return a string of
different length to its input?
2) What exception do you get when you craft an impossible class hierarchy?
    a. ValueError b. TypeError c. types.ClassInheritanceError d. SyntaxError
3) What does `from __future__ import braces` do?
4) Which operator, removed from Python 3.0, can be reinstated with a
'joke' future directive?
5) What is the difference between the `/` and `//` operators in Python
2.7? In Python 3.x?

Got any other tricky questions to add?

ChrisA



More information about the Python-list mailing list