sprite = codesters.Sprite("knight1", -175, -150)
sprite.set_speed(2)
def park_scene():
stage.set_background("park")
t = codesters.Teacher()
try:
say = t.find_function('say')
line = say[0][0]
tval1 = t.get_indent_at_line(line)
tval2 = say[0][1].lower()
except:
say = "DNE"
line = "DNE"
tval1 = "DNE"
tval2 = "DNE"
t1 = TestObjective()
t1.add_success(tval1 ==4 and 'i should hurry' in tval2, "Great job!")
t1.add_failure(say == [] or say == "DNE", "Did you add a say command inside your function?")
t1.add_failure(tval1 < 4, "Did you indent your say command inside your function?")
t1.add_failure(tval1 > 4, "It looks like you indented your say command too much. Make sure it's indented 4 spaces inside your function.")
t1.add_failure('i am a sprite' in tval2, "Did you change the string in your say command?")
try:
params = t.get_parameters_for_function('move_forward')
tval4 = int(params[0][0])
except:
params = "DNE"
tval4 = "DNE"
t2 = TestObjective()
t2.add_success(tval4 == 550, "Great job!")
t2.add_failure(tval4 == "DNE", "Did you add a move forward command?")
t2.add_failure(tval4 < 525, "Make sure your sprite is moving far enough so that it no longer appears on the stage.")
t2.add_creative(tval4 >= 525 and tval4 != 550 and tval4 != "DNE", "That's a good distance to move, also!")
try:
move = t.find_function('move_forward')
line = move[0][0]
tval3 = t.get_indent_at_line(line)
except:
move = "DNE"
line = "DNE"
tval3 = "DNE"
t3 = TestObjective()
t3.add_success(tval3 == 4, "Great job!")
t3.add_failure(tval3 < 4, "Did you indent your Move Forward command inside your function block?")
t3.add_failure(tval3 > 4, "It looks like you\'ve indented your Move Forward command too far. Make sure it\'s indented 4 spaces inside your function block.")
tester = TestManager()
tester.add_test_list([t1, t2, t3])
tester.run_tests()
tester.display_first_feedback()
-
Run Code
-
Activity Submitted!
Submit Work
-
Next Activity
-
Stop Running Code
-
Show Chart
-
Show Console
-
Reset Code Editor
-
Codesters How To (opens in a new tab)