Solution
Hints
- A turtle always turns relative to the direction it is currently facing, not relative to the screen -- right(90) is always a quarter turn from wherever it is already pointing.
- Four equal sides and four equal 90-degree turns is exactly what makes a shape a square; the same forward/right pair just repeats.
- If the last corner does not line up with the first, check that every right(90) actually ran -- a skipped or extra turn is the most common bug.
Steps
- Import turtle and create one Turtle instance.
- Call forward(100) then right(90) four separate times, one after another -- no loop needed for a shape this small.
- After the fourth turn, the turtle faces its original direction again and the four corners meet, closing the square.
- For the stretch goal, repeat the same four-step pattern with a shorter forward distance (e.g. 50) to draw a smaller square, starting from wherever the turtle currently sits.
import turtle
monty = turtle.Turtle()
monty.shape('turtle')
monty.forward(100)
monty.right(90)
monty.forward(100)
monty.right(90)
monty.forward(100)
monty.right(90)
monty.forward(100)
monty.right(90)
See also: Sample Turtle Graphics Program (Chapter 14, Computational Thinking, Scratch & Python): https://dmccreary.github.io/learning-python/python-labs/02-simple-square/ -- this card's solution matches that lab's own reference code exactly.