BreakingExpress

Teach Python with the Mu editor

Teaching children to code may be very standard in colleges. Many years in the past, within the days of the Apple II and Logo programming, I realized about turtle graphics. I loved studying easy methods to program the digital turtle and later serving to college students to do the identical.

About 5 years in the past, I realized about Python’s turtle module, and it was the segue to my Python journey. Soon, I began utilizing the turtle module to show college students Python programming fundamentals, together with utilizing it to create fascinating graphics.

Get began with Python’s turtle module

On a Linux or macOS laptop, you’ll be able to simply open a terminal, enter the phrase python, and you may see the Python shell.

If you’re utilizing a Windows laptop, you’ll need to put in Python first by going to the Python web site and downloading the most recent steady model.

Next, import the turtle module into Python with import turtle or import turtle as t. Then you can begin having some enjoyable creating turtle graphics.

Meet Mu

In the early days of my Python journey, I used IDLE, Python’s built-in improvement surroundings. It was a lot simpler than getting into instructions into the Python shell, plus I may write and save applications for later use. I took some on-line programs and browse many glorious books about Python programming. I taught academics and college students easy methods to create turtle graphics utilizing IDLE.

IDLE was an enormous enchancment, however at PyConUS 2019 in Cleveland, I noticed a presentation by Nicholas Tollervey that modified the way in which I realized and taught Python. Nick is an educator who created Mu, a Python editor particularly for younger programmers (and even older ones like me). Mu may be put in on Linux, macOS, and Windows. It’s straightforward to make use of and comes with glorious documentation and tutorials.

On Linux, you’ll be able to set up Mu from the command line.

On Ubuntu or Debian:

$ sudo apt set up mu-editor

On Fedora or related:

$ sudo dnf set up mu

Or, you should utilize Python to do the set up. First, guarantee you’ve gotten Python three put in:

$ python --version

If that fails, attempt:

$ python3 --version

Assuming you’ve gotten Python model three or higher, set up Mu utilizing pip, the Python bundle supervisor:

$ python -m pip set up mu-editor --user

Then you’ll be able to run Mu from the command line or create a shortcut utilizing:

$ python -m pip set up shortcut mu-editor --user

Mu is put in by default on the Raspberry Pi, which is a good plus. In the previous couple of years, I’ve launched college students to the Raspberry Pi and Python programming utilizing the Mu editor.

How to show Python with Mu

Mu is an effective way to indicate college students how straightforward it’s to get began with Python. Here’s how I educate my college students to begin utilizing it.

  1. Open the Mu editor.
  2. Enter import turtle to import the Turtle module, so you may get the turtle shifting. My first lesson is drawing a easy sq. in Python code.
  3. Save this program, ensuring that the file title ends in .py.
  4. Run this system. Running even a easy program like that is energizing—it is enjoyable to see the graphical output of a program you wrote.

Beyond the fundamentals

After this straightforward lesson, I clarify that there are some methods to simplify and increase on the fundamentals the scholars have realized. One is creating an easier turtle object, import turtle as t. Then I introduce a for loop as one other method to attract a sq. with the turtle.

Next, I present easy methods to create a my_square perform as one other method to attract a sq..

Later, I increase on this idea by introducing different turtle module strategies, together with penup, pendown, and pencolor. Soon, my college students are growing extra advanced applications and iterating on them.

I’m all the time wanting to be taught, and I’d like to understand how you’re educating Python at school or at house. Please share your expertise within the feedback.

Exit mobile version