stage.set_background("park")
sprite = codesters.Sprite("person3")
sprite.glide_to(-100, 50)
# text = codesters.Text("text", x, y, "color")
text = codesters.Text("I went to the park!", 0, -200, "blue")
stage.wait(1)
sprite.move_right(400)
transition1 = sprite.ask("Choose a transition from the sequence category.")
text.set_text(transition1)
sprite.move_left(200)
stage.set_background("underwater")
text.set_text("I like turtles.")
stage.wait(2)
transition2 = sprite.ask("Enter another word")
text.set_text(transition2)
stage.set_background("jupiter")
text.set_text("Then I was in space!")
stage.wait(2)
transition3 = sprite.ask("Enter yet another word")
text.set_text(transition3)
stage.set_background("city")
text.set_text("Then I went to a city")
stage.wait(2)
t = codesters.Teacher()
try:
params = t.find_function('set_text')
tval1 = params[6][1].lower()
except:
tval1 = "DNE"
try:
params2 = t.find_function('ask')
tval2 = params2[3][1].lower()
except:
tval2 = "DNE"
t1 = TestObjective()
t1.add_success(tval1 != "DNE" and "hello codesters" not in tval1, "Great job!")
t1.add_failure(tval1 == "DNE", "Did you add a Set Text command?")
t1.add_failure("hello codesters" in tval1, "Did you change the text to describe your new scene?")
t1.add_failure('"transition4"' in tval1, "Oops! Make sure you're using the variable transition4. Remove the quotes!")
t2 = TestObjective()
t2.add_success(tval2 != "DNE" and "transition4" in tval2, "Great job!")
t2.add_failure(tval2 == "DNE", "Did you add an Ask command?")
t2.add_failure("yes or no" in tval2, "Did you change the text in the Ask command?")
t2.add_failure("transition4" not in tval2 and "choice" in tval2, "Make sure you change the name of the Ask variable to transition4.")
tester = TestManager()
tester.add_test_list([t2, t1])
tester.run_tests()
tester.display_first_feedback()
-
Run Code
-
Activity Submitted!
Enviar Trabajo
-
Actividad Siguiente
-
Stop Running Code
-
Show Chart
-
Show Console
-
Reset Code Editor
-
Codesters How To (opens in a new tab)