Give the Gift of Python¶
Talk given at SF Python Holiday Party on December 5, 2018.
Who am I?¶
Python programmer.
Hundreds of hours of classroom instruction.
What we need?¶
Interest!
Typing skills.
Math: Arithmetic, Algebra, Geometry
Setup¶
Install Python, https://www.python.org/
Run IDLE,
$ python -m idlelib.idle
Write code.
Open the Turtle Window¶
>>> from turtle import *
>>> reset()
Commands¶
>>> forward(100)
>>> right(90)
>>> forward(100)
>>> right(90)
>>> forward(100)
>>> right(90)
>>> forward(100)
>>> right(90)
Loops¶
>>> reset()
>>> for each in range(4):
... forward(100)
... right(90)
Shapes¶
>>> reset()
>>> begin_fill()
>>> for each in range(4):
... forward(100)
... right(90)
>>> end_fill()
Dots¶
>>> reset()
>>> dot(10)
Functions¶
>>> def square():
... begin_fill()
... for each in range(4):
... forward(100)
... right(90)
... end_fill()
>>> reset()
>>> square()
Colors¶
>>> reset()
>>> color('orange')
>>> square()
Locations¶
>>> reset()
>>> up()
>>> goto(-100, 100)
>>> down()
>>> square()
Inputs¶
listen
onclick
onkey
Animation¶
ontimer
hideturtle
tracer
clear
update
>>> reset()
>>> hideturtle()
>>> tracer(False)
>>> square()
>>> clear()
>>> square()
>>> update()
Tips¶
help(…)
undo(…)
Embrace copy/paste
Close window/reset()
Activities¶
Spell your name.
python -m pip install freegames
Notes¶
Start simple! Start easy! Start plain!
Focus on fun! No PEP8. No Pylint.
Make it readable! Say it aloud.
No special shells! No IPython.
Show them mistakes! Red is your favorite color!
No virtual environments!
If they’re not ready, don’t push them!
No dunder methods or attributes! No __name__ or __main__.