-1
程序說名字「問題沒有定義」爲什麼? 我定義它,當我說questio =「大小」,如果語言==「恩」其他\python name not defined to draw polygons
import locale
def ask_language():
language = input("Language: en, es, ca")
return language
def ask_number(language):
question = "Size: " if language == 'en' else \
"Tamaño: " if language == 'es' else \
"Mida: "
size = input(float(question))
locale.setlocale(locale.LC_ALL, "")
if language == 'en':
f_size = float(size)
elif language == 'es':
f_size = locale.atof(size)
else:
f_size = locale.atof(size)
return f_size
def move_turn(turtle, size, degrees):
turtle.forward(size)
turtle.left(degrees)
def polygon(turtle, size, sides):
for _ in range(sides):
move_turn(turtle, size, 360/sides)
def draw_polygon(size):
import turtle
window = turtle.Screen()
alex = turtle.Turtle()
alex.shape('turtle')
alex.speed(1)
polygon(alex, size, 5)
window.exitonclick()
turtle.TurtleScreen._RUNNING = True