0% found this document useful (0 votes)
12 views

2. Python Turtle Programs

This document outlines a lesson on Python programming focusing on the use of Turtle graphics, variables, and control structures like IF and nested conditions. It includes tasks for creating shape programs that utilize user input for various parameters and demonstrates how to implement conditions for colors based on input values. The lesson concludes with a plenary task for peer assessment and reflection on the objectives.

Uploaded by

sara
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

2. Python Turtle Programs

This document outlines a lesson on Python programming focusing on the use of Turtle graphics, variables, and control structures like IF and nested conditions. It includes tasks for creating shape programs that utilize user input for various parameters and demonstrates how to implement conditions for colors based on input values. The lesson concludes with a plenary task for peer assessment and reflection on the objectives.

Uploaded by

sara
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Python Programming

Programming

Lesson 2: Python Turtle (IF and


Nested Conditions)

http://www.yahmad.co.uk/
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 printing statements and joining variables


Understand how use a for loop to repeat commands.

Outcomes Time
Task 1 Shape Program
Task 2 Shape Program (IF Condition)
Task 3 Shape Program (Nested Conditions)
Task 4 Extension

http://www.yahmad.co.uk/
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 1 – Shape Program

Variables: User will input


values into the variables for
the following:
• Shape
• Number of steps per each side
Programming

• The number of sides


• Pen and Fill colour

The angle will be worked out


automatically by dividing 360
by the number of sides.

Print statements will print


user input. (+ joins variables)

1. Enter the script shown to the left.


2. Run the program.
The program will create any shape using a
for loop based on your input.
Task 2 – Shape Program (IF Condition)

IF Condition:

If the user has


entered less than 100
steps per each side
Programming

then the outline of


the shape will be red
and the fill will be
green.

If the steps per each


side is not less than
100 then the outline
of the shape will be
black and the fill will
be yellow.
Task 3 – Shape Program (Nested Conditions)

Nested Condition:

If the sides is equal (==) to 3


the Pen Colour will be Orange
and the Fill Colour will be
Programming

Purple.

If the sides is equal (==) to 4


the Pen Colour will be Blue
and the Fill Colour will be
gold.

If the sides is equal (==) to 5


the Pen Colour will be Red
and the Fill Colour will be
Green.

Else:

Pen Colour will be Black and


the Fill Colour will be Yellow.
Task 4 – Extension

Create your own program using the Python


Turtle. You must include the following:
Programming

• Variables – User to be prompted to enter


their answers
• Print Statements
• IF or Nested Conditions
• For Loops
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 printing statements and joining variables


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 data have you input into the programs?

http://www.yahmad.co.uk/

You might also like