stage.set_background_color("lightblue")
# sprite = codesters.Rectangle(x, y, width, height, "color")
sprite = codesters.Rectangle(0, 0, 700, 50, "gold")
t = codesters.Teacher()
params = t.get_parameters_for_function("Rectangle")
spins = t.get_parameters_for_function("turn_left")
try:
tval1 = params[0][3]
except:
tval1 = "DNE"
try:
tval2 = spins[0][0]
except:
tval2 = "DNE"
t1 = TestObjective()
if tval1 == "DNE":
t1.add_failure(tval1 == "DNE", "Did you delete the Rectangle command?")
else:
tval1 = int(tval1)
t1.add_success(tval1 == 100, "Great job!")
t1.add_failure(tval1 == 50, "Did you change the height parameter to 100?")
t1.add_failure(tval1 <50, "Too short! Try making the stripe taller.")
t1.add_failure(tval1 > 150, "Too tall! Try making the stripe shorter.")
t1.add_creative(tval1 >100 and tval1 <= 150, "That's a good height too!")
t2 = TestObjective()
t2.add_success(tval2 == "45", "Great job!")
t2.add_failure(tval2 == "DNE", "Did you add a Turn Left tool?")
t2.add_failure(tval2 != "45" and tval2 != "DNE", "Is the integer in your Turn Left command 45?")
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)