Tech Lesson 11-5:  Drawing Shapes with Python and Turtle - Basic Python Programming with JES

CSTA Level I Standard 4: (3rd to 5th) Use general purpose productivity tools and peripherals to support personal productivity, remediate skill deficits, and facilitate learning throughout the curriculum.
CSTA Level I Standard 5: (3rd to 5th) Use technology tools for individual and collaborative writing, communication, and publishing activities to create presentations, and publishing activities to create presentations for audiences inside and outside the classroom.

Basic Skills:

M4M2: Students will understand the concept of angle and how to measure angles.
M4G1: Students will define and identify the characteristics of geometric figures through examination and construction.
M4P5:  Students will represent mathematics in multiple ways.
M5A1: Students will represent and interpret the relationships between quantities algebraically.
M5G1: Students will understand congruence of geometric figures and the correspondence of their vertices, sides, and angles.

Programming Skill Objectives:
Identify and define an interpreted computer scripting language. (Scratch and Python) - Programming languages that run directly without being compiled.
Create text based code in JES (Jython Environment for Students) and save into their file area with proper extension.  (ProgramName.py)
Use following commands to draw shapes and designs with Turtles.
• turtle.forward(distance)
• turtle.turn(degrees)
• turtle.moveTo(x, y)
• turtle.color = red (blue, green . . .) -or- (255, 255, 255) RGB notation
• turtle.penUp()
• turtle.penDown()
Use following commands to create Worlds and Turtles.
• earth = makeWorld(400, 400)
• turtle = makeTurtle(earth)
Troubleshoot and solve coding errors and problems.
Run code from written programs and from Interactions Window.
Define and use Functions
Use the "for i in range(x)" commands to do repeats.
Use comments in program to describe what code will do.

Lesson Objectives:

Students write and save a Python Code file named LastnameShapes.py in their file area using JES
Students demonstrate how to open JES.
Students demonstrate how to open JES with the "python LastnameShapes.py" command.
Student program draws square and triangle with proper dimensions.

Requirements:
1.  Use JES to draw a square using combinations of turtle.forward() and turtle.turn() commands.
2.  Use JES to draw a triangle using combinations of urtle.forward() and turtle.turn() commands.
3.  Write and save a program in JES that draws a square and a triangle.  Save as LastnameShapes.py in student's file area.
4.  Run student program with JES.

Extras:
1.  Define Functions in Python that draw square and triangle.
2.  Use parameters to all user to define size of shape.
3.  Create Designs using different colors and spirals.

Process:  (Directions for Students)

Session 1:  Using the Python with JES

1.  Review Drawing shapes with Scratch.
2.  Introduce text based programming Languages.  (Python, Java, C# . . .)
3.  Demonstrate Python with JES.
a. Click JES icon
b. create world and turtle:

c. Save file as "LastnameShapes.py" in file area.
d. Click "Load Program" to intitiate the World.
e. Your World should look like:

4.  Students use Interactions Area to draw a square.  (Trial and error - Teacher provide guidance as needed)

Example Commands:
turtle.forward(100)
turtle.turn(90)

5.  Students use Interactions Area to draw a triangle.
6.  Students explore drawing different shapes and paths with Python commands.

Session 2:  Creating Python Programs with JES

1.  Review drawing with Python and Turtle and JES
2.  Using Interactions is good for short experiments.  Longer programs need to be coded and saved.
3.  Demonstrate JES - do simple program and save:  (SimpleSquare.py)

4.  Run program:
a. Save Program
c. Type following in Interactions Window:

makeSquare(turtle, 100)

5.  Students create, save, and run a triangle program.

Session 3: Using Functions to create designs

1. Demonstrate Repeat Statements and Functions to create a spiral Square - emphasize the use of tabs in Python.

2. Students write code for Square Spriral by adding lines 16 to 25 to their Square program.
3. Students run their programs.