How to "wow" someone new to Python

Marko Rauhamaa marko at pacujo.net
Fri Jan 16 10:20:14 EST 2015


Chris Angelico <rosuav at gmail.com>:

> Scenario: You're introducing someone to Python for the first time.
> S/he may have some previous programming experience, or may be new to
> the whole idea of giving a computer instructions. You have a couple of
> minutes to show off how awesome Python is. What do you do?

My experience is that if you have your "customer" try their hand on
programming and complete a simple challenge, they'll be extremely
impressed. "Did I manage that?"

On the other hand, if you want to demo your greatest achievements at the
screen, they will be left unmoved. "Even my favorite Zynga game looks
cooler than that."

> I was thinking along the lines of a simple demo in the REPL, showing
> off some of Python's coolest features. But then I got stuck on the
> specifics. What are Python's best coolnesses? What makes for a good
> demo?

I would advise steering clear of the REPL and go directly to writing a
program and executing it. Maybe the classic ASCII graphics presentation
of the sine wave:

========================================================================
#!/usr/bin/env python3

import time
import math

def main():
    for angle in range(0, 100000, 5):
        print(int((1 + math.sin(math.radians(angle))) * 35) * "*")
        time.sleep(0.1)

if __name__ == "__main__":
    main()
========================================================================

> Ideally, this should be something that can be demo'd quickly and
> easily, and it should be impressive without going into great details
> of "and see, this is how it works on the inside". So, how would you
> brag about this language?

I'd recommend not skipping the traditional boilerplate (see my example).
Be professional from the start.


Marko



More information about the Python-list mailing list