stage.set_background("underwater")
score = 0
score_board = codesters.Display(score)
weak_pws = ["password", "password123", "hello1", "snuffles", "123456"]
strong_pws = ["GgbvTa581!@", "@Mjrc0olguy!", "007jmSB0nd!", "108turt!es762", "Avv3SoMe!305"]
all_pws = weak_pws + strong_pws
# text = codesters.Text("text", x, y, "color")
password = codesters.Text("password", 100, 200, "red")
def interval():
# add any other actions...
rand_x = random.randint(-225, 225)
rand_y = random.randint(-225, 225)
rand_pw = random.choice(all_pws)
password.set_text(rand_pw)
password.go_to(rand_x, rand_y)
stage.event_interval(interval, 2)
def click(sprite):
global score
# add other actions...
password.event_click(click)
t = codesters.Teacher()
try:
tval1 = t.find_function('get_text')[0][1].replace(' ', '')
tval2 = t.get_indent_at_line(t.find_function('get_text')[0][0])
except:
tval1 = "DNE"
tval2 = "DNE"
t1 = TestObjective()
t1.add_success(tval1 == 'pw_text=password.get_text()' and tval2 == 4, "Great job!")
t1.add_failure(tval1 == "DNE", "Did you add a Get Text command to your Click Event?")
t1.add_failure('pw_text=' not in tval1, "Did you change the name before the equals sign to pw_text?")
t1.add_failure('password.' not in tval1, "Did you change the name in front of .get_text() to password?")
t1.add_failure(tval2 < 4, "Make sure you indent your Get Text command inside your event!")
tester = TestManager()
tester.add_test_list([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)