Python Programming
Programming
Lesson 1: Python Turtle
http://www.yahmad.co.uk/
Introduction to Python and Variables
Objectives
Understand how to create and save programs in Python.
Understand the use of Variables and how to assign them values.
Programming
Understand the use of different commands such as PenUp/PenDown, goto, forward, backward,
left, right and t.begin_fill() & t.end_fill().
Understand how use a for loop to repeat commands.
Outcomes Time
Task 1 Open Python and Save a New File
Task 2 Import Turtle and PenUp/Down
Task 3 Create a Triangle
Task 4 Creating shapes using a for loop
Task 5 Extension: Create the additional shapes
http://www.yahmad.co.uk/
Task 1 – Open Python and Save a New File
Programming
1. Make a new
Python Folder
2. Open Python Idle.
3. Click on File >>
New
4. Save the program
into your Python
Folder
5. Run the Program
Run > Run Module
Task 2 – Import Turtle and PenUp/Down
Variable:
Placeholder to
t=
store values
which can be
called upon later 1. Import the Turtle
Programming
in the program into Python.
2. Enter the script
PenDown: Will and run the
move turtle and program.
draw a line.
3. You will be
prompted to enter
PenUp: Will move
the colour for
turtle and not draw
each line.
a line.
Two lines will be drawn
with a gap.
goto: Set the start
point of the turtle
using the X & Y axis
Extension: Add an extra line with the same
spacing as the previous line.
Task 2 – Create a Triangle
Variable: User will input values into the
variables for pen_color and fill_color
t.color will include the pen and fill colour
Programming
1. You need to create a simple
program to draw and fill a
triangle.
t.begin_fill() &
2. You will be prompted to enter
t.end_fill(): Colours
the Pen and Fill Colour.
in the shape
Extension: Change each length to 200
Task 2 – Create a Triangle
Script to move 3. Enter the following code at the end of
the turtle to the the same program. Then run the
start point
without drawing program.
a line.
Identify which steps are being repeated.
Programming
Extension: Draw a pentagon
to the left of the square.
The start point for the
pentagon will be:
X(-300)
Y(0)
Side (100) left (72)
Start point to
draw the turtle
Task 3 – Creating shapes using a for loop
1. You need to create a simple
program to create a triangle
and square.
2. You will be prompted to enter
Programming
the Pen and Fill Colour.
Script to move the turtle to the
start point for the square without
drawing a line. Extension: Draw a pentagon to the left of
the square using a for loop.
The start point for the pentagon will be:
X(-300)
Y(0)
Side (100) left (72)
Task 4 – Create the following Shapes
Programming
1. You need to create a simple program to create the following shapes.
2. You may use a for loop to reduce your code.
Task 4 – Create the following Shapes
Programming
1. You need to create a simple program to create the following shapes.
2. You may use a for loop to reduce your code.
Plenary – Refer to the Lesson Objectives
Objectives
Understand how to create and save programs in Python.
Understand the use of Variables and how to assign them values.
Programming
Understand the use of different commands such as PenUp/PenDown, goto, forward, backward,
left, right and t.begin_fill() & t.end_fill().
Understand how use a for loop to repeat commands.
Plenary Task (Q&A)
Peer assess each other scripts.
Question: What is the purpose of variables?
Question: What are the different data types of commands you have used in this lesson.
http://www.yahmad.co.uk/