stage.set_background_color("black")
# sprite = codesters.Point(x, y)
sprite = codesters.Point(50, 100)
sprite.set_color("green")
sprite.pen_down()
def right_key():
sprite.move_right(20)
# add other actions...
stage.event_key("right", right_key)
def left_key():
sprite.move_left(20)
# add other actions...
stage.event_key("left", left_key)
def up_key():
sprite.move_up(20)
# add other actions...
stage.event_key("up", up_key)
def down_key():
sprite.move_down(20)
# add other actions...
stage.event_key("down", down_key)
my_list = ["red", "orange", "yellow", "green", "blue", "indigo", "violet"]
def space_bar():
my_var = random.choice(my_list)
# add other actions...
stage.event_key("space", space_bar)
t = codesters.Teacher()
try:
color_line = t.find_text("set_color")[1][0]
tval1 = t.get_indent_at_line(color_line)
except:
tval1 = -1
try:
tval2 = t.get_parameters_for_function('set_color')[1][0]
except:
tval2 = "DNE"
t2 = TestObjective()
t2.add_success(tval2 == 'my_var', "Great job!")
t2.add_failure(tval2 == "DNE", "Did you add a Set Color in the space_bar event?")
t2.add_failure('"' in tval2 or "'" in tval2, "Oops! my_var shouldn't be in quotes.")
t2.add_failure(tval2 != "DNE" and tval2 != 'my_var', "Did you change the color to my_var?")
tester = TestManager()
tester.add_test_list([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)