简单的Python-3程序中的语法错误无效

时间:2010-08-12 19:15:18

标签: python syntax python-3.x syntax-error

from TurtleWorld import *
import math

bob = Turtle()
print(bob)

draw_circle(turtle, r):
    d = r*2
    c = d*math.pi
    degrees = 360/25
    length = c // 25
    for i in range(25):
        fd(turtle, length)
        rt(turtle, degrees)

draw_circle(bob, 25)

wait_for_user()

第7行的问题:

  

draw_circle(turtle,r):

编译器只告诉我语法错误并突出显示冒号 那条线的尽头。 我确定我错过了一些简单的东西,但代码对我来说是正确的。

4 个答案:

答案 0 :(得分:2)

在python中,我们使用def关键字定义函数..比如

def draw_circle(turtle, r):
    # ...

答案 1 :(得分:1)

你需要写:

def draw_circle(turtle, r):

define a function

答案 2 :(得分:1)

答案 3 :(得分:0)

我想,如果其他三个答案都不够明显,我应该先告诉你,你需要先def?

def draw_circle(turtle, r):

@People重复: 说真的,我们还能得到1个答案吗?我相信3(4,如果你加我)是不够的

相关问题