Reputation: 11
Good day,
I'm trying to write this python code for this two part problem and here is what I have so far. How somebody be able to help me finish it and or correct it?
Here is my attempt:
#Question 11a
Print("Question 11a")
import turtle
s = turtle.Screen()
t = turtle.Turtle()
def halfSquare(t, length):
for i in range(2)
t.down()
t.forward(length)
t.right(90)
#Question 11b
print("Question 11b")
def halfSqaures(t, initial, increment, reps):
halfSquare(length):
Please help!!
Upvotes: 0
Views: 1039
Reputation: 55469
I'll give you a bit of help on the first part, but I won't write the code because this is your homework, not mine.
In your halfSquare
function you have a SyntaxError
(you're missing the :
on the end of the for
statement) and an IndentationError
(the code inside the for
loop). Also, t.right(90)
should be t.left(90)
.
BTW, you can put turtle.mainloop()
at the end of your program to wait for the user to close the window.
Ok. I see you're having some difficulties, so I'll post a fully-working program for you. But please try to understand how it works.
import turtle
print("Question 11a")
t = turtle.Turtle()
def halfSquare(t, length):
t.down()
for i in (0, 1):
t.forward(length)
t.left(90)
#halfSquare(t, 100)
print("Question 11b")
def halfSquares(t, initial, increment, reps):
length = initial
for i in range(reps):
halfSquare(t, length)
length += increment
halfSquares(t, 20, 20, 10)
turtle.mainloop()
Upvotes: 1