# Module Inputs
import turtle
# Define Functions
def drawshape(s,l,c):
angle = 360 / s
a.pencolor(c)
for i in range(s):
a.forward(l)
a.left(angle)
# Create Turtle
a = turtle.Turtle
a.pensize(5)
a.pendown()
# Title and Credits
print('Shape Drawer by Alex Thornton')
# While Loop
answer = 'y'
while True:
if answer != 'y':
break
# Create Turtle Window
wn = turtle.Screen()
# Inputs
sides = int(input("\nHow many sides? ")
length = int(input('What length of sides? ')
color = input('What colour? ')
# Call Functions from Inputs
drawshape(sides,length,color)
# Exit (From Turtle Window)
wn.exitonclick()
# Input For Restart
answer = input("\nAgain? (y/n) ")
# Exit Program
print("\nThank you for using this program!")
exit = input('Please press enter to exit.')
在长度输入上,我在第 31 行收到错误输入的解析错误。该程序从用户那里获取边长、边数和形状颜色的输入。这是作为 GCSE 计算作业完成的。