Slice of Py

Python is a programming language that is widely used in science, engineering and education. Both our TECH Mission and Robotics Challenge Mission provide a taste of programming with Python. The activities found here are intended for students in 6th through 8th grade, or beyond. They will get you started programming with Python and then challenge you to create and share original projects as you learn new skills.

Content Standard Alignment

Getting Started

Slice of Py programming activities use the Mu editor – a Python code editor for beginning programmers.

Your first step is to download and install the Mu editor.

Mu Editor Installation Video

Mu Download & Install Link

Can’t download software on your computer?

There are other Python editors you can use online.

Online Python Editor Options

Using Modes in Mu Editor

There are several Modes you can select from when you start using the Mu editor. Mu will behave differently depending on the Mode you select. Make sure you read instructions carefully so you select the required Mode for each activity.

To learn more about using Modes in Mu, watch this video tutorial:

Modes in Mu Video

Have questions? Contact us via email: stem@afrlnewmexico.com

(Make sure you write “Slice of Py Question” in the Subject Line of your email.)

Introduction to Programming with Python & the Mu Editor

Introduction Video

Writing Your First Python Program

Often the first program that beginning programmers write is a “Hello World!” program. This will also be your first program in Slice of Py. This program will introduce you to the print function and some of the rules you must use to create a correct sequence of symbols in Python. The correct sequence of symbols for a programming language is referred to as its “syntax”.

To start programming with Python and learn how to create your own “Hello World” program, open this tutorial: 

Print Function Tutorial

For each programming skill introduced in Slice of Py, there will be one or more sample programs for you to copy and paste into the Mu Editor. Then, you can explore editing the code in that program to make it your own.

Using Variables in Python

In computer science, a variable is a container that can store different kinds of information. You can use print functions in Python to display information stored in variables.

To learn how to write programs using variables in Python, open this tutorial: 

Variables in Python Tutorial

For each programming skill introduced in Slice of Py, there will be one or more sample programs for you to copy and paste into the Mu Editor. Then, you can explore editing the code in that program to make it your own.

Python Turtle Graphics

A module is a file containing Python code. Turtle is a Python graphics module that you can use to make drawings in a window with a pen. You define the color, size, shape, and other attributes of the pen. Your code will control the movement of the pen to create drawings as simple or complex as you want.

To learn how to draw with code in Python, open this tutorial: 

Drawing with Code Tutorial

For each programming skill introduced in Slice of Py, there will be one or more sample programs for you to copy and paste into the Mu Editor. Then, you can explore editing the code in that program to make it your own.

Python Challenge #1

Your first Python Challenge is to draw your name using Python code. You may include other shapes, pictures or designs.

We have provided a sample solution to help you get started.

“Larry” Program

Share your Python Challenge #1 solution with us by sending your finished program via email to: 

stem@afrlnewmexico.com

We’ll display the challenge solutions we receive in our Slice of Py Gallery.

(Make sure you write “Slice of Py Challenge #1” in the Subject Line of your email.)

Have questions? Contact us via email: stem@afrlnewmexico.com

(Make sure you write “Slice of Py Question” in the Subject Line of your email.)

For Loops & Computer Interactions

Introduction Video

For Loops

“For loops” enable programmers to repeat sections of code a number of times. With turtle drawings, “for loops” can be used to draw complex geometric shapes with fewer lines of code than would be needed without “for loops”.

Open this tutorial to learn how to write programs that use “for loops” in Python:

For Loops Tutorial

For each programming skill introduced in Slice of Py, there will be one or more sample programs for you to copy and paste into the Mu Editor. Then, you can explore editing the code in that program to make it your own.

Computer Interactions

Computer interaction is the dialog between people and computers. You can design simple questions that can store user input in variables that can be used in your program. Programs can be designed to respond to user input.

Open this tutorial to learn how to write programs in Python that interact with users in: 

Computer Interactions Tutorial

For each programming skill introduced in Slice of Py, there will be one or more sample programs for you to copy and paste into the Mu Editor. Then, you can explore editing the code in that program to make it your own.

Python Challenge #2

Your second Python Challenge is to create an interactive program that will allow users to select drawing options like pen color, size, shape or other variables used in the program. 

We have provided two sample solutions to help you get started.

Draw a Polygon with User Input Program

Draw a Mosaic with User Input Program

Share your Python Challenge solution with us by sending your finished program via email to: 

stem@afrlnewmexico.com

We’ll display the challenge solutions we receive in our Slice of Py Gallery.

(Make sure you write “Slice of Py Challenge #2” in the Subject Line of your email.)

Have questions? Contact us via email: stem@afrlnewmexico.com

(Make sure you write “Slice of Py Question” in the Subject Line of your email.)

Turtle Race

Introduction Video

The Turtle Race game will provide you with an opportunity to combine and practice some Python skills learned so far. The Turtle module, Random module, Time module and for loops will be used to make a turtle race game. 

Open this tutorial to learn creative ways to use loops and modules to make a turtle race game.

Turtle Race Tutorial

For each programming skill introduced in Slice of Py, there will be one or more sample programs for you to copy and paste into the Mu Editor. Then, you can explore editing the code in that program to make it your own.

Python Challenge #3

Your third Python Challenge is to create a turtle race game. Include some changes to the game you created in the tutorial. Some suggested modifications include:

^

Add more turtles to the race

^

Make the track wider and longer

^

Change from solid to dashed lines

^

Add decorations like a checkered finish line

^

Other modifications you may think of

Make a Turtle Race Game

Share your Python Challenge solution with us by sending your finished program via email to: 

stem@afrlnewmexico.com

We’ll display the challenge solutions we receive in our Slice of Py Gallery.

(Make sure you write “Slice of Py Challenge #3” in the Subject Line of your email.)

Have questions? Contact us via email: stem@afrlnewmexico.com

(Make sure you write “Slice of Py Question” in the Subject Line of your email.)

Strengthen your communication and problem solving skills!