Draw a square with less code - Python

Last edited: 24th June 2022

This code introduces using a loop for drawing shapes.

import turtle
pen=turtle.Turtle()
for i in range (0,4):
    pen.forward(100)
    pen.right(90)

Run the code and see what happens. Can you change the pen.right(90) code to a different number so it draws a hexagon instead?

HINT: Change the 4 so it loops more than four times.


This lesson is part of the Simple Python Challenges Course

Agree
We use cookies to provide you with a better service. Continue browsing if you are happy with this.