Part A.
Define a function triangle that draws an equilateral triangle
and takes two parameters:
1. t, a turtle object
2. size, the side length of an equilateral triangle

Part C:
Define a function flagLine that takes 3 parameters and draws a line
of flags (triangles). You MUST use the function defined in Part A:
1. pen, a turtle object
2. length, the side length of an equilateral triangle
3. num, number of flags in the line

and I need to test both part A and C.

here's what I got for part A:

``````def triangle(t, size):
angle = 360/3
for i in range(3):
t.forward(size)
t.left(angle)
``````

and I have the code that draws two flagline triangles.

``````def triangle(t, size):
angle = 360/3
for i in range(3):
t.forward(size)
t.left(angle)
import turtle
ascreen = turtle.Screen()
r = turtle.Turtle()

for i in range(2):
triangle (r,100)
r.fd(100)
ascreen.exitoneclick()
``````

but I am not so sure what would I do with Part C.
I would very appriciate if you help me with this.
Thank you!

Could it be that the third parameter in you new function is the number of times in your for loop?

You are almost there, just have to create another function. I am not sure where the pen() belongs. Maybe something like this ...

``````import turtle

def triangle(tu, size):
angle = 360/3
for i in range(3):
tu.forward(size)
tu.left(angle)

def flagline(tu, length, num):
tu.pen(pencolor='blue')
for i in range(num):
triangle (tu, length)
tu.fd(length)

ascreen = turtle.Screen()
tu = turtle.Turtle()

length = 100
num = 3
flagline(tu, length, num)

ascreen.exitonclick()
``````
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.