我的龜已經死了!他不會使用我的循環。 nmbrOfSides
正在重新調整3
順便說一句。有關我可能會忽略的任何提示?我的龜已經死了
import turtle
counter = 0
def poly_side_calculation (student_number):
sides = 3 + student_number % 3
return sides ####function returns 3 when I enter student number
print("welcome to my TURTLE demonstration.\n")
studentNmbr = int(input("Please enter your student number to get started: "))
print("Here are your choices for the color of your polygon. You can choose red, green, blue, yellow, cyan, magenta, black or white.")
fill_color = input("Please enter the color that you would like your polygon to be: ")
poly_side_length = int(input("Please enter the length of your polygon side: "))
nmbrOfSides = poly_side_calculation(studentNmbr)
vertex_angle = 360/nmbrOfSides
turtle.color("black", fill_color)
turtle.pensize(5)
turtle.showturtle()
turtle.pendown()
turtle.begin_fill()
turtle.setpos(-150,150)
while counter <= nmbrOfSides:
turtle.forward = (poly_side_length)
turtle.left = vertex_angle
counter = counter + 1
turtle.end_fill()
謝謝你這麼多 – user3291152