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")
t = codesters.Teacher()
try:
say = t.find_function('say')
line = say[1][0]
tval1 = t.get_indent_at_line(line)
tval2 = say[1][1].lower()
except:
say = "DNE"
line = "DNE"
tval1 = "DNE"
tval2 = "DNE"
t1 = TestObjective()
t1.add_success(tval1 == 4 and 'i made it' 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?")
t1.add_creative('i made it' not in tval2, "It looks like you want your sprite say something else. Creative choice!")
try:
params = t.get_parameters_for_function('go_to')
tval4 = int(params[0][0])
tval5 = int(params[0][1])
except:
params = "DNE"
tval4 = "DNE"
tval5 = "DNE"
t2 = TestObjective()
t2.add_success(tval4 == -175 and tval5 == -150, "Great job!")
t2.add_failure(tval4 == "DNE", "Did you add a Go To command inside your function?")
t2.add_failure(tval4 == -100, "Did you change the x-coordinate in the Go To command?")
t2.add_failure(tval5 == -50, "Did you change the y-coordinate in the Go To command?")
t2.add_creative(tval4 != -175, "That's a good spot for your sprite, too!")
t2.add_creative(tval5 != -150, "That's a good spot for your sprite, too!")
try:
go = t.find_function('go_to')
line = go[0][0]
tval3 = t.get_indent_at_line(line)
except:
go = "DNE"
line = "DNE"
tval3 = "DNE"
t3 = TestObjective()
t3.add_success(tval3 == 4, "Great job!")
t3.add_failure(tval3 < 4, "Did you indent your Go To command inside your function block?")
t3.add_failure(tval3 > 4, "It looks like you\'ve indented your Go To command too far. Make sure it\'s indented 4 spaces inside your function block.")
tester = TestManager()
tester.add_test_list([t2, t3, 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)