LESSON – Drawing with Python
Lesson Objectives
- Using python to create complex patterns
Success Criteria
- understand how to use iteration to draw a simple shape in Python
- create a patterns using iteration in Python
- show programming skills to create complex patterns
Keywords
- Turtle
- Graphical User Interface
- Iteration
- Patterns
Commands
- turtle.pencolor(“Red”)
- turtle.forward(100)
- turtle.right(90)
- turtle.fillcolor(“Brown”)
Starter
Can you identify the shapes which used to crate this complex patterns:
Task 1 – Drawing simple Hexagon shape with “for loop”:
Last lesson you have learnt how to draw simple shapes which was one of them hexagon.
Procedural code vs Iterative code
What you have learnt last lesson was procedural code(see above picture), which means you write every action one after another.
However, we have learnt in previous lessons that there is a better way to improve our programs using loops (iterative programming).
Watch the below video and try to understand how the code has been improved by using iterations.
Now it is your turn to create those shapes using iteration
Open IDLE (Python GUI)
Do not forget: To be able to draw in python on top of your program you need to insert:
import turtle
Draw square, equilateral triangle and hexagon using loops. Make sure you have save them separately and print screen each output and paste them in a word document to print end of the lesson.
When you finish your code test your program using run (F5) tab.
Change your drawing graphic from arrow to turtle add the following code on top of your program after import turtle:
turtle.shape(“turtle”)
You can use below commands to make your turtle do different things. Following will change the color of the line:
turtle.pencolor(“Red”)
Python has many different commands to help you draw different shapes. Here are some of those listed below:
turtle.forward() | Go forward |
turtle.backward() | Go backward |
turtle.right() | Turn right |
turtle.left() | Turn left |
turtle.penup() | Lifts the pen up so you can move the turtle without drawing |
turtle.pendown() | Drops the pen back onto the screen so you can draw |
turtle.fillcolor(“Brown”) | Changes the fill colour to brown(or other colour) |
turtle.pencolor(“Red”) | Changes the pen colour to red (or other colour) |
turtle.begin_fill() | Begins to fill the shape |
turtle.end_fill() | End the filling sequence |
turtle.shape(“turtle”) | Changes the turtle shape from arrow to turtle |
turtle.bgcolor(“lightyellow”) | Changes the background colour of your screen |
Task 2 – Crating a pattern using triangle
Watch the following video and try to understand how you can create simple patterns using iterative programming.
Before modifying your program make sure you do save as and save your file as simplePatern.py
Create a pattern using square, equilateral triangle and hexagon using loops. Make sure you have save them separately and print screen each output and paste them in a word document to print end of the lesson.
Task 3 – Modify your program and create a complex patterns
Modify your last program (make sure you do save as and name it complecPattern.py)
create a patterns like the one below:
Following video should help you with this task:
Task 4 – Creating complex shapes using Python
By now you have learnt how to create complex patterns. Now, you need to create complex shapes that you have seen in your starter activity one like the below image:
Following video should help you with this task:
Challenge yourself and create following images.
- Use a equilateral triangle. Equilateral triangle has 3 sides and external angle is 120 degrees
- Use a Square. Square has 4 sides and external angle is 90 degrees
- Use a hexagon to create complex images. Hexagon has 6 sides and external angle is 60 degrees.
- Use a Pentagon to create complex images. Pentagon has 5 sides and external angle is 72 degrees.
Home learning – due in two weeks
Maurits Cornelis Escher (1898-1972)
On a A4 page research and write a report about MC Escher who was developed tessellating shapes and patterns as an art form.
- Short history (Who is he, where is he from and impacts he has made in art world)
- Examples of his work
- Include your research links
You can find your home learning in your Show My Homework account.
Below link to help you with your task but you have expected to do your own search too:
MC Escher bibliography