In a medieval castle, the crenelation (a.k.a battlement) is a parapet at the top of a wall that has regularly spaced squared openings for archers to shoot through.
In this challenge, we are going to use Python Turtle to create repeating patterns such as the crenellation of a medieval castle.
First, let’s investigate how to draw a horizontal line using python Turtle:
Task #1:
Your task is to edit the above code to create a single crenellation pattern as follows: (Instead of a horizontal line going across the screen).
To do so you will need to use a few Python Turtle instructions including:
- myPen.forward(20)
- myPen.left(90)
- myPen.right(90)
Task #2: Repeating Pattern
In order to repeat this crenellation pattern to go across the screen, we will use a for loop.
for i in range (0,10): myPen.left(90) myPen.forward(15) myPen.right(90) myPen.forward(20) myPen.right(90) myPen.forward(15) myPen.left(90) myPen.forward(20)
Task 3: Alternative Crenellation Patterns…
Your task is to tweak the above code to recreate the following repetitive patterns…
Solution...
The solution for this challenge is available to full members!Find out how to become a member:
➤ Members' Area