A good way to do this is to define a circle with parameters and just use what you want. Also, since the hexagon is repeated, you can use the for loop to build many sides for it. This is how I solved it.
from turtle import * setup() x = 200 # Use your own value y = 200 # Use your own value def circles (radius, colour): penup() pencolor (colour) goto (0,radius) pendown () setheading (180) circle (radius) penup() circles (100, "red") circles (50, "yellow") circles (25, "green") def hexagon (size_length): pendown () forward(size_length) right (60) goto (x, y) for _ in range (6): hexagon (50) exitonclick ()
In this case, you do not need to save the definition of the circle and just add your own parameters, and hexigon can be easily executed using the for loop.
source share