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!")
stage.wait(2)
bridge_scene()
t = codesters.Teacher()
try:
func = t.find_text('def battle_scene')
tval1 = func[0][1]
except:
func = "DNE"
tval1 = "DNE"
try:
dragon_getter = t.find_text('Sprite')
line = dragon_getter[1][0]
tval2 = t.get_indent_at_line(line)
tval3 = dragon_getter[1][1]
except:
dragon_getter = "DNE"
line = "DNE"
tval2 = "DNE"
tval3 = "DNE"
try:
say = t.find_function('say')
tval4 = say[2][1].lower()
line = say[2][0]
tval5 = t.get_indent_at_line(line)
except:
say = "DNE"
tval4 = "DNE"
line = "DNE"
tval5 = "DNE"
t1 = TestObjective()
t1.add_success('def battle_scene():' in tval1, "Great job!")
t1.add_failure('battle' not in tval1, "Did you create a function and name it battle_scene?")
t2 = TestObjective()
t2.add_success(tval2 == 4 and 'battle' in tval3, "Great job!")
t2.add_failure('dragon' not in tval3, "Did you put a dragon sprite in your function?")
t2.add_failure('sprite =' in tval3, "Did you rename the sprite in your battle_scene function?")
t2.add_failure(tval2 < 4, "Did you indent your dragon in your new function?")
t2.add_failure(tval2 > 4, "Make sure your sprite is nested 4 spaces inside your function.")
t2.add_creative('dragon' not in tval3, "It looks like you chose a different sprite. Creative choice!")
t2.add_creative('150, -150' not in tval3, "You chose a different position for your dragon to appear. Creative choice!")
t3 = TestObjective()
t3.add_success('dragon' in tval4 and tval5 == 4, "Great job!")
t3.add_failure(tval4 == "DNE", "Did you add a say command in your battle_scene function?")
t3.add_failure('i am a sprite' in tval4, "Did you change the string in the Say command?")
t3.add_failure(tval5 < 4, "Did you indent your say command 4 space inside your battle_scene function?")
t3.add_failure(tval5 > 4, "Make sure your Say command is indented 4 spaces inside your function.")
t3.add_creative('dragon' not in tval4, "You chose a different sprite to battle. Creative choice!")
tester = TestManager()
tester.add_test_list([t1, t2, t3])
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)