python未定义_未定义Python:“”

这是我的代码:# This program makes the robot calculate the average amount of light in a simulated room

from myro import *

init("simulator")

from random import*

def pressC():

""" Wait for "c" to be entered from the keyboard in the Python shell """

entry = " "

while(entry != "c"):

entry = raw_input("Press c to continue. ")

print("Thank you. ")

print

def randomPosition():

""" This gets the robot to drive to a random position """

result = randint(1, 2)

if(result == 1):

forward(random(), random())

if(result == 2):

backward(random(), random())

def scan():

""" This allows the robot to rotate and print the numbers that each light sensors obtains """

leftLightSeries = [0,0,0,0,0,0]

centerLightSeries = [0,0,0,0,0,0]

rightLightSeries = [0,0,0,0,0,0]

for index in range(1,6):

leftLight = getLight("left")

leftLightSeries[index] = leftLightSeries[index] + leftLight

centerLight = getLight("center")

centerLightSeries[index] = centerLightSeries[index] + centerLight

rightLight = getLight("right")

rightLightSeries[index] = rightLightSeries[index] + rightLight

turnRight(.5,2.739)

return leftLightSeries

return centerLightSeries

return rightLightSeries

def printResults():

""" This function prints the results of the dice roll simulation."""

print " Average Light Levels "

print " L C R "

print "========================="

for index in range(1, 6):

print str(index) + " " + str(leftLightSeries[index]) + " " + str(centerLightSeries[index]) + " " + str(rightLightSeries[index])

def main():

senses()

pressC()

randomPosition()

scan()

printResults()

main()

所以,我在运行程序时遇到了这个错误。在

^{pr2}$

我明白我一定是做错了与报税表有关的事。我不确定是否只能在用户定义函数的末尾返回一个变量。如果这是真的,那么我应该分离scan():函数。不管怎样,如果你能帮我解决这个错误,我会很感激的。此外,当我成功完成我的课程时,这也是我要寻找的结果:

Click Here

我希望完成的平均值,如图所示,但我不担心他们在这一点上,只是从光传感器的值列表。我不需要达到那些确切的数字,数字将在模拟器中变化。在

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值