"Use two if statements. One to test to see if the random integer is a 1, then turn left, move forward, and count. The second to test if the random integer is 2, then turn right and move forward. You only need to return either the left or right count, since the function can only return one thing. "
It is pretty straight forward but i just couldn't get it here is what i have so far.
# Programmer : Nicholas Fallon
# May 28, 2010
# movement401.py
from myro import*
init("simulator")
def pressC():
askQuestion( "Click on C to continue!" ,[ "C", "Quit"])
speak("Lets Begin")
def dfdfd():
s= input("Enter a speed (' -1 ' - '1' respectively): ")
t=input("How many seconds should the robot move:?")
return s,t
def movement(speed):
for d in range(s):
result = randint(1,2)
if (result <= 1):
turnLeft(s,t)
forward(s,t)
def movement2(time):
for d in range(t):
result = random()
if(result <= 2):
turnRight(t,s)
forward(t,s)
def main():
dfdfd()
pressC()
speed = movement(s)
time = movement2(t)
main()
I get a few errors, and like i said Ive been bumping heads with this thing for a while I have tried many different tricks but could not get it.
Oh yea i forgot It keeps saying " s " is not defined but when the program prompts the user for numeric input it should be passed through. If you get what i am saying


Sign In
Create Account

Back to top










