CODE: TT08
Background Colors
Firstly let's make the background into a graph style colour.
import turtle
turtle.bgcolor("blue")
Speed it up
Drawing can take some time, so we might want to speed up the turtle.
This is the slowest that the turtle can draw:
turtle.speed(1)
This is the fastest that the turtle can draw with animation:
turtle.speed(10)
However the very fastest it can draw is:
turtle.speed(0)
The catch is that it no longer shows what it is drawing until it is done.
Firstly let's make the background into a graph style colour.
import turtle
turtle.bgcolor("blue")
Speed it up
Drawing can take some time, so we might want to speed up the turtle.
This is the slowest that the turtle can draw:
turtle.speed(1)
This is the fastest that the turtle can draw with animation:
turtle.speed(10)
However the very fastest it can draw is:
turtle.speed(0)
The catch is that it no longer shows what it is drawing until it is done.
Counting backwards
print(turtle.screensize())
This little bit of code prints the screen size, which by default is 400 by 300.
So far most of the loops we have seen just count up by 1, but actually you can do all sorts of counts.
for i in range(300,-300,-10):
turtle.penup()
turtle.goto(-400,i)
turtle.pendown()
turtle.forward(600)
Let's have a closer look at this for loop:
for i in range(300,-300,-10):
for i in range(start number, end number, step):
This code doesn't just go up the stairs in steps of 1, but jumps down the steps.
Exercise 1: Gridded Paper
So I've effectively drawn some lovely lined paper, but we want grids! Can you draw the y axis lines to make a grid?
This little bit of code prints the screen size, which by default is 400 by 300.
So far most of the loops we have seen just count up by 1, but actually you can do all sorts of counts.
for i in range(300,-300,-10):
turtle.penup()
turtle.goto(-400,i)
turtle.pendown()
turtle.forward(600)
Let's have a closer look at this for loop:
for i in range(300,-300,-10):
for i in range(start number, end number, step):
This code doesn't just go up the stairs in steps of 1, but jumps down the steps.
Exercise 1: Gridded Paper
So I've effectively drawn some lovely lined paper, but we want grids! Can you draw the y axis lines to make a grid?