stage.set_background("park")
sprite = codesters.Sprite("person3")
sprite.glide_to(-100, 50)
# sprite = codesters.Text("text", x, y, "color")
text = codesters.Text("I went to the park!", 100, 200, "red")
t = codesters.Teacher()
txt_func = t.get_parameters_for_function('Text')
try:
tval2 = int(txt_func[0][1])
except:
tval2 = "DNE"
try:
tval3 = int(txt_func[0][2])
except:
tval3 = "DNE"
try:
tval4 = txt_func[0][3]
except:
tval4 = "DNE"
t1 = TestObjective()
t1.add_success(tval2 == 0 and tval3 == -200, "Great job!")
t1.add_failure(tval2 == "DNE", "Oops! Did you delete the Text in Color command?")
t1.add_failure(tval3 == "DNE", "Oops! Did you delete the Text in Color command?")
t1.add_failure(tval2 == 100, "Did you change the x coordinate?")
t1.add_failure(tval3 == 200, "Did you change the y-coordinate?")
t1.add_creative(tval2 != 0 and tval2 != 100 and tval2 != "DNE", "That's a good place for text, too!")
t1.add_creative(tval3 != -200 and tval3 != 200 and tval3 != "DNE", "That's a good pace for text, too!")
t2 = TestObjective()
t2.add_success("blue" in tval4, "Great job!")
t2.add_failure(tval4 == "DNE", "Oops! Did you delete the Text in Color command?")
t2.add_failure('red' in tval4, "Did you change the text color?")
t2.add_creative('blue' not in tval4 and 'red' not in tval4 and tval4 != "DNE", "That's a good color, too!")
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)