Basically wanting to make these two patterns, both dependent on n (number of rows for 1 and number of triangles for 2) which here is 5 for both cases. See the pictures below for the desired output.
Here is what I came up with for the first one. Draws dots going down with each iteration in the inner loop adding one dot to the left. Ideally, I want it to make the dots going left to right and then each iteration in the inner loop adding one dot up.
def drawTriangularSeries(myTurtle, n):
sideLength = 10
x = 0
y= 200
myTurtle.penup()
myTurtle.goto(x, y)
for row in range(n+1):
for col in range(row):
myTurtle.dot()
myTurtle.back(sideLength)
myTurtle.back(sideLength)
y -= sideLength
myTurtle.goto(x, y)
Here is what I did for the second one. Whenever it goes to draw the next triangle, it draws it below the previous one.
def drawTriangle(myTurtle, dotsPerSide, startX, startY):
sideLength = 10
x = startX
y = startY
myTurtle.penup()
myTurtle.goto(x, y)
for i in range(dotsPerSide+1):
x += sideLength * i
y += sideLength * i
myTurtle.goto(x, y)
for j in range(i + 1):
for k in range(j):
myTurtle.dot()
myTurtle.back(sideLength)
myTurtle.back(sideLength)
y -= sideLength
myTurtle.goto(x, y)
How do I rewrite the loops such that it makes the picture? Here is current output: Current Output Here's what it's supposed to look like, where problem one is making the last triangle and problem two is making the whole series Correct Ouput
