• Homework
  • Thirds
  • Upper Thirds
  • Fourth
  • Divisions
    • ICT
    • Computer Science
  • Fifth
  • Lower Sixth
  • Upper Sixth
    • Upper Sixth Theory
  • Blog
  • Careers
  • Unity
  • Networking

Advanced Turtle Challenges

Draw a multi-point star - here is an example for 15 sides


for i in range(15):
    turtle.right(180-(180/15))
    turtle.forward(120)
    
turtle.exitonclick()

Picture
Can you adapt this to work for any number of sides, including odd and even numbers.
This is harder than it looks.

Draw a spiral

Picture
Hint:  to draw a spiral you should gradually increase the amount that the turtle moves forward each turn.

You can do this by creating a variable
myVariable = 0
Then, every time that the turtle turns, add a fixed amount to the variable
myVariable = myVariable + 1

Draw a multi-coloured spiral

This is a bit harder.

First you need to set up a list of colour values
tcolours = ("red","green","blue","yellow")
tcolours is just a variable, but it's a special type of variable called a 'list'.  It's a fixed list with four values:

tcolours[0] is "red"
tcolours[1] is "green"
tcolours[2] is "blue"
tcolours[3] is "yellow"

we can use this variable in our turtle.color() command.  We can also use a control variable to change between 0,1,2 and 3 so that we get different colours
colorvalue = 0
for i in range(numberofsides):
    colorvalue = colorvalue +1
    if colorvalue > 3:
        colorvalue = 0
    turtle.color(tcolours[colorvalue])
Picture

Draw a clock face

Picture
For this challenge you'll need to use turtle.penup(), turtle.goto() and turtle.pendown().  You can also use turtle.stamp() to draw the turtle pictures.

The following line will put the turtle in the middle of the screen, without changing the direction that it's pointing:
turtle.goto(0,0)
The rest is up to you :-)

Tell the time - make a working clock

You can get the time from Python.
To do that you'll need to add an additional import command on the very first line of your program
import datetime, turtle
Then ask python to find the current time.   I've used a variable called 'currenttime' but you can call it anything
currenttime = datetime.datetime.now()
From this you can find the hours and the minutes
currenttime.hour
currenttime.minute
There's more, you can get seconds, day of the week etc:

More turtle challenges

Picture
Powered by Create your own unique website with customizable templates.