import turtle class Circle: def __init__(self, x, y, radius): self.x = x self.y = y self.radius = radius def __str__(self): return "Circle at ({self.x}, {self.y}) with radius {self.radius}" def draw_circles(circles): t = turtle.Turtle() for circle in circles: t.goto(circle.x, circle.y) t.circle(circle.radius) # Create some Circle objects c1 = Circle(0, 0, 75) c2 = Circle(10, 10, 100) c3 = Circle(50,50,200) # Draw the circles on a canvas draw_circles([c1, c2, c3])
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter