stage.set_background("halfcourt")
sprite = codesters.Sprite("player4")
sprite.go_to(215, -175)
net = codesters.Sprite("basketballnet")
net.go_to(215, 175)
ball = codesters.Sprite("basketball")
x = random.randint(-100, 150)
ball.go_to(x, -25)
stage.set_gravity(10)
stage.set_bounce(.8)
ball.set_gravity_off()
net.set_gravity_off()
try:
tval1 = left_count
except:
tval1 = "DNE"
try:
tval2 = down_count
except:
tval2 = "DNE"
t1 = TestObjective()
t1.add_success(tval1 == 0, "Great job!")
t1.add_failure(tval1 == "DNE", "Did you add an integer variable and rename it left_count?")
t1.add_failure(tval1 == 25, "Did you change the value of left_count to 0?")
t1.add_failure(tval1 == "This is a string.", "Oops! Did you add a Sting Variable by mistake?")
t1.add_failure(tval1 == 2.34, "Oops! Did you add a Float Variable instead?")
t1.add_failure(tval1 != 0, "Make sure left_count is equal to 0.")
t2 = TestObjective()
t2.add_success(tval2 == 0, "Great job!")
t2.add_failure(tval2 == "DNE", "Did you add an integer variable and rename it down_count?")
t2.add_failure(tval2 == 25, "Did you change the value of down_count to 0?")
t2.add_failure(tval2 != 0, "Make sure down_count is equal to 0.")
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)