Python Turtle: Subroutine Parameters
Starter: What will this code do when executed?
import turtle
t = [Link]()
#defining square subroutine
def square():
for n in range(4):
[Link](200)
[Link](90)
#calling square subroutine
square()
Adding a parameter
We can adapt the function so that we can draw a square that is
any size.
Task: Type in the code above, into a new program.
Call the square subroutine three more times.
Each time you call the subroutine enter a different value into the
parameter.
Take a screenshot of your code and the output and paste
in the box below.
Task: Type in the code above, into a new program.
Call the triangle subroutine three more times.
Each time you call the subroutine enter a different value into the
parameter.
Take a screenshot of your code and the output and paste
in the box below.
Task: Copy the code above into a new program.
-Move the turtle to a different location on the screen.
-Call the colouredSquare subroutine.
Do this three times.
No square should overlap with any other square.
Take a screenshot of your code and the output and
paste in the box below.
Task: Copy the code above into a new program.
Call the squareCol subroutine three more times.
No square should overlap with any other square.
Take a screenshot of your code and the output and
paste in the box below.
Extension Task
Using the squareCol subroutine try to make some of these
patterns.
For each pattern take a screenshot of your code and the output
and paste into one of the boxes below.