I have to draw an n sided polygon using an isosceles triangle function.
It should be only 3 lines inserted under def draw_pie(n, r).
Can you help me figure out how?

import math
import turtle

def draw_pie(n, r):
    """Draws a pie divided into radial segments.
    n: number of segments
    r: length of the radial spokes
    """

def isosceles(r, angle):
    """Draws an isosceles triangle.
    The turtle starts and ends at the peak, facing the middle of the base.
    r: length of the equal legs
    angle: half of peak angle, in degrees
    """
    y = r * math.sin(angle * math.pi / 180)

    turtle.right(angle)
    turtle.forward(r)
    turtle.left(90+angle)
    turtle.forward(2*y)
    turtle.left(90+angle)
    turtle.forward(r)
    turtle.left(180-angle)

# draw a hexagonal (6-sided) pie
size = 100
draw_pie(6, size)

# wait for user to close the window
turtle.done()
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.