Category: Broad General Education

S3 – Python Turtle

This weeks task is to solve the maze. You are not allowed to touch the black lines.

You can use any Python Turtle commands you want including

  • goto(x,y)
  • right(deg)
  • left(deg)
  • forward(length)

Save the image as maze.png and use the boilerplate code below in Thonny to start the task.


# Solve the maze
# Mr Stratton
# 7/6/19

from turtle import *
# Help here https://docs.python.org/3/library/turtle.html
setup(1000,600) # set the window size to 480x360 pixels
bgcolor('yellow') # set BG to yellow
bgpic("maze.png") # BG pic only works with PNG and GIF
title("Mr. Stratton's Maze Tutorial") # Title of window
color("red") # Colour line
# shape("arrow") # Shape of the turtle (“arrow”, “turtle”, “circle”, “square”, “triangle”, “classic”)
turtlesize(3) # size of turtle (easier for some kids to see)
pensize(3) # Set the size of the pen

penup()
goto(-420,220)
pendown()
# vvvvvv Enter your code below here vvvvvv

After you have solved the maze answer these questions:

  1. How many programming steps did you take?
  2. Can you reduce the number of steps?

Save a new copy of the program and edit it to make it more efficient (fewer lines). The number of extra lines that my program needed is below.

Read more

BGE – Images on websites

The <img> tag is used to add an image to a webpage. <img> uses attributes to descibe the image and its location.


<img src="egg.jpg" alt="A picture of a chocolate egg">

  • src – The value of this attribute is the full name of the image file, in this case egg.gif which is in the same directory as the html file.
  • alt – The value of this attribute is a description of the image. This is used in case the image fails to download or it can be read aloud by screen readers.