stage.set_background("winter")
sprite = codesters.Sprite("person12")
sprite.go_to(-125, -150)
frosty = codesters.Sprite("snowman")
frosty.go_to(100, -125)
snow = codesters.Sprite("snowflake3")
snow.go_to(100, 75)
greeting = codesters.Text("Happy Holidays!")
greeting.go_to(0, 200)
greeting.set_color("yellow")
def click(sprite):
sprite.say("I hope your holidays are great!")
sprite.turn_left(360)
# add other actions...
sprite.event_click(click)
def space_bar():
# add other actions...
snow.set_x_speed(5)
stage.event_key("space", space_bar)
t = codesters.Teacher()
try:
params = t.find_function('set_y_speed')
tval1a = params[0][1]
tval1b = t.get_indent_at_line(params[0][0])
except:
tval1a = "DNE"
tval1b = "DNE"
t1 = TestObjective()
t1.add_success("snow" in tval1a and tval1b == 4, "Great job!")
t1.add_failure(tval1a == "DNE" or tval1b == "DNE", "Did you add a Set y Speed command to the Space Bar event?")
t1.add_failure(tval1b != 4, "Make sure your Set y Speed command is indented four spaces inside the Space Bar event.")
t1.add_failure('sprite' in tval1a, "Did you change the name in front of Set y Speed to snow?")
t2 = TestObjective()
t2.add_success("2" in tval1a, "Great job!")
t2.add_failure("5" in tval1a, "Did you change the number in the Set Speed command?")
t2.add_failure(tval1a == "DNE", "Did you add a Set y Speed command?")
tester = TestManager()
tester.add_test_list([t1, t2])
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)