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.
Turtle Py
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
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. It will introduce you to some of the rules you must use to create a correct sequence of symbols in Python. We refer to the correct sequence of symbols for a programming language as “syntax”.
To learn how to start programming with Python and how to create your own “Hello World” program, watch this video tutorial:
“Hello World!” Video
For each programming skill introduced in Slice of Py, there will be a sample program for you to copy and paste into the Mu Editor. Then, you should explore how you can edit the code in that program to make it your own.
“Hello World!” Program
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, watch this video tutorial:
Variables in Python Video
For each programming skill introduced in Slice of Py, there will be a sample program for you to copy and paste into the Mu Editor. Then, you should explore how you can edit the code in that program to make it your own.
________ Program
Python Turtle Graphics
Drawing with Code Tutorial
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 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 Input
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. In this Slice of Py, user input, variables, for loops, while loops, sleep functions and random functions will be used to create computer interactions.
Open this tutorial to learn how to write programs that interact with users with user input, variables, for loops, while loops, sleep functions and random functions in Python:
Computer Input 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
Turtle Race 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:
- Adding more turtles to the race
- Making the track wider and longer
- Changing from solid to dashed lines
- Adding decorations like a checkered finish line
- Or, 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.)
Python Lists
Python Lists Video
Python lists enable programmers to organize and work with information. Lists store sequences of data that can be combined and compared with other lists. List items can be accessed with an index which keeps track of the order of items in the list. For loops can be used to access and use multiple items in a list.
Open this tutorial to learn how to write programs that use Python lists:
Python Lists 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 #4
This Python Challenge is to create an interactive program that will share a list of favorite foods or other items with a user of your program. Your program should then ask your user to provide a list of foods. The program should then compare lists and print a list of items you have in common with your user.
Python List 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.)
Pygame
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 make computer video games with Python:
Pygame Zero 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 #5
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 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 #5” 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.)