target = codesters.Sprite("triangle", 100, 50)
target.set_opacity(.5)
target.reflect_x_axis()
text = codesters.Text('target', 100, -125)
text.set_size(.8)
text.set_opacity(.8)
stage.set_background("grid")
sprite = codesters.Sprite("triangle")
sprite.go_to(100, 50)
t = codesters.Teacher()
reflect = t.find_function('reflect_x_axis')
try:
tval1 = reflect[0][1]
tval2 = sprite.get_x()
tval3 = sprite.get_y()
except:
tval1 = "DNE"
tval2 = "DNE"
tval3 = "DNE"
t1 = TestObjective()
t1.add_success(tval1 != "DNE", "Great job!")
t1.add_failure(tval1 == "DNE", "Did you use a reflection command?")
t1.add_failure(tval2 == "DNE", "Oops! Did you delete your triangle?")
t2 = TestObjective()
t2.add_success(tval2 == 100 and tval3 == -50, "Great job!")
t2.add_failure(tval2 == "DNE", "Oops! Did you delete your triangle?")
t2.add_failure(tval2 == -100, "Oops! Did you reflect over the y_axis instead? Try the x!")
t2.add_failure(tval2 != 100 and tval2 != "DNE", "Keep trying until your triangle overlaps with the goal!")
t2.add_failure(tval3 != -50 and tval3 != "DNE", "Keep trying until your triangle overlaps with the goal!")
tester = TestManager()
tester.display_graphics = False
tester.add_test_list([t1, t2])
tester.run_tests()
tester.display_first_feedback()
if tval2 == 100 and tval3 == -50 and tval1 == True:
text.set_text(" ")
-
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)