sprite = codesters.Sprite("knight1", -175, -150)
sprite.set_speed(2)
def park_scene():
stage.set_background("park")
sprite.say("I should hurry to the castle!")
sprite.move_forward(550)
park_scene()
def bridge_scene():
stage.set_background("drawbridge")
sprite.go_to(-175, -150)
sprite.say("I made it!")
t = codesters.Teacher()
try:
func_call = t.find_text('bridge_scene')
line = func_call[1][0]
tval1 = t.get_indent_at_line(line)
tval2 = func_call[1][1]
except:
func_call = "DNE"
line = "DNE"
tval1 = "DNE"
tval2 = "DNE"
try:
waits = t.find_function('wait')
line2 = waits[0][0]
tval3 = t.get_indent_at_line(line2)
tval4 = waits[0][1]
except:
tval3 = "DNE"
tval4 = "DNE"
t1 = TestObjective()
t1.add_success(tval1 == 0 and "bridge_scene()" in tval2, "Great job!")
t1.add_failure('bridge_scene()' not in tval2, "Did you call your function by typing its name followed by parens?")
t1.add_failure(tval1 > 0, "Make sure your Call Function command is not indented.")
t2 = TestObjective()
t2.add_success(tval3 == 4 and tval4 == 'stage.wait(2)', "Great job!")
t2.add_failure(tval4== "DNE", "Did you add a Wait to your bridge_scene function?")
t2.add_failure('stage' not in tval4, "Oops! Make sure you're telling the stage to wait for 2 seconds.")
t2.add_failure(tval3 < 4, "Make sure you indent your Wait command inside your function!")
t2.add_failure(tval3 > 4, "Make sure you're only indenting your Wait command 4 spaces inside your function.")
t2.add_creative('stage.wait' in tval4 and '2' not in tval4, "That's a good amount of time to wait also!")
tester = TestManager()
tester.add_test_list([t2, t1])
tester.run_tests()
tester.display_first_feedback()
-
Run Code
-
Activity Submitted!
Enviar Trabajo
-
Actividad Siguiente
-
Stop Running Code
-
Show Chart
-
Show Console
-
Reset Code Editor
-
Codesters How To (opens in a new tab)