########################################################################
# PLACE LIST CREATIONS HERE #
########################################################################
stage_list = ["moon", "mars", "jupiter", "pluto", "space", "city"]
head_list = ["head1", "head2", "head3", "head4", "head5", "head6"]
########################################################################
# PLACE ALL OTHER CODE BELOW THIS #
########################################################################
stage_image = stage_list[1]
stage.set_background(stage_image)
random_head = random.randint(0, 5)
head_image = head_list[random_head]
t = codesters.Teacher()
try:
tval1 = t.find_function('Sprite')[0][1]
except:
tval1 = "DNE"
try:
tval2 = head.get_x()
tval3 = head.get_y()
except:
tval2 = "DNE"
tval3 = "DNE"
t1 = TestObjective()
t1.add_success('head_image' in tval1, "Great job!")
t1.add_failure(tval1 == "DNE", "Did you add a Sprite at Position and name it head?")
t1.add_failure('"codester"' in tval1, "Did you change the sprite's image label?")
t1.add_failure("head_image" not in tval1, "Did you change the sprite's image label to head_image?")
t1.add_failure('"head_image"' in tval1 or "'head_image'" in tval1, "Make sure head_image is not in quotes!")
t2 = TestObjective()
t2.add_success(tval2 == 0 and tval3 == 83, "Great job!")
t2.add_failure(tval2 == "DNE" or tval3 == "DNE", "Did you name the sprite head?")
t2.add_failure(tval2 != 0, "Make sure your x-coordinate is 0 so your sprite lines up on the stage.")
t2.add_failure(tval3 != 83, "Make sure your y-coordinate is 83 so your sprite lines up in the stage.")
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)