# sprite = codesters.Rectangle(x, y, width, height, "color")
start = codesters.Rectangle(0, -250, 500, 50, "red")
# sprite = codesters.Rectangle(x, y, width, height, "color")
finish = codesters.Rectangle(0, 250, 500, 50, "green")
my_list = [-150, -50, 50, 150]
for value in my_list:
pass # delete after adding indented code
# add code here
# sprite = codesters.Rectangle(x, y, width, height, "color")
sprite = codesters.Rectangle(0, value, 500, 50, "gray")
# sprite = codesters.Sprite("image", x, y)
sprite = codesters.Sprite("turtle1", 0, -240)
sprite.set_size(.2)
sprite.turn_left(90)
def interval():
my_var = random.choice(my_list)
if my_var == -150 or my_var == 50:
pass # delete after adding indented code
# add your code here
sprite = codesters.Sprite("car1", -400, my_var)
sprite.turn_right(90)
sprite.set_size(0.5)
sprite.set_x_speed(2)
stage.event_interval(interval, 0.5)
t = codesters.Teacher()
ifs = t.find_block("if")
sprites = t.find_function("Sprite")
try:
tval1 = ifs[1][1].lower().replace(' ','')
tval1_indent = t.get_indent_at_line(ifs[1][0])
except:
tval1 = "DNE"
tval1_indent = "DNE"
try:
tval2 = sprites[2][1].lower().replace(' ','')
tval2_indent = t.get_indent_at_line(sprites[2][0])
except:
tval2 = "DNE"
tval2_indent = "DNE"
t1 = TestObjective()
t1.add_success(('ifmy_var==-50ormy_var==150:' in tval1 or 'ifmy_var==150ormy_var==-50' in tval1) and tval1_indent == 4, "Great Job!")
t1.add_failure(tval1 == "DNE", "Did you add if or inside the interval event?")
t1.add_failure(tval1 != "DNE" and ('ifmy_var==-50ormy_var==150:' not in tval1 and 'ifmy_var==150ormy_var==-50' not in tval1), "Did you change the variables and values in the if statement?")
t1.add_failure(('ifmy_var==-50ormy_var==150:' in tval1 or 'ifmy_var==150ormy_var==-50' in tval1) and tval1_indent == 8, "Make sure the new if statement is not also indented in the previous if statement!")
t1.add_failure(('ifmy_var==-50ormy_var==150:' in tval1 or 'ifmy_var==150ormy_var==-50' in tval1) and tval1_indent != 8 and tval1_indent != 4, "Make sure the if statement is indented once inside the interval event!")
t2 = TestObjective()
t2.add_success(tval2 != "DNE" and tval2_indent == 8, "Great job!")
t2.add_failure(tval2 == "DNE", "Did you add Car 2 inside the new if statement?")
t2.add_failure(tval2 != "DNE" and tval2_indent != 8, "Make sure Car 2 is indented two times! Once for the event, once for the new if statement.")
tester = TestManager()
tester.add_test_list([t1, t2])
tester.run_tests()
tester.display_first_feedback()