How I teach Python with open source tools
I love to teach Python. I start by beginning where the learner begins. My first question is, “How would you like to learn Python?”
They usually answer, “What’s Python?”
That’s when I give them some examples of websites built with Python they might already be familiar with. I also provide examples of using Python in data science, engineering and web development.
Most folks are intimidated when you try to introduce computer programming because their first efforts failed or someone told them programming is difficult. I show them a simple print statement that easily demonstrates how much the Python syntax is like the language they speak.
>>> print("Hello World")
Hello World
Unless they are Linux or macOS users, they might need help installing Python on their computer. I guide them through downloading Python from the Python.org website and installing it on their computer. Next, I help them set up a development environment. For many users this is IDLE.
A good Python IDE
For a young student, I introduce Mu, a great development environment for elementary and middle school students. Adults and older students might use VSCodium.
Python REPL
I often introduce new users to the REPL so they can execute their code easily. Then I show them how to write a simple program with a print statement print("Hello World")
and save it as a text file with a .py
extension. I explain that the .py
extension is necessary for Python to recognize the program.
Turtle
Then, I introduce them to Python fundamentals, including variables, strings, numbers, and basic operations. I suggest Python libraries like the Turtle, which even adults find fascinating. I start simply in the REPL:
import turtle
turtle.forward(100)
turtle.right(90)
This example demonstrates how easy it is to write code in Python and how just a few lines can produce a graphic on their display. Then I show how to draw a square:
import turtle
turtle.forward(100)
turtle.right(90)
turtle.forward(100)
turtle.right(90)
turtle.forward(100)
turtle.right(90)
turtle.forward(100)
turtle.right(90)
Then I cover control structures like the if statement, elif, for, and while. I demonstrate drawing that same square quickly and easily with a for loop:
import turtle
for x in range(4):
turtle.forward(100)
turtle.right(90)
Teaching Python is a gift
When you teach, it’s important to begin where the learner is and engage them in their own edification. This approach has them leaning in for more information, ensuring they gain skill and competency.
Your local public library might be a great place to find students who want to learn Python. Most libraries would happily have you volunteer to help their patrons.