stage.set_background("underwater")
score = 0
score_board = codesters.Display(score)
weak_pws = ["password", "password123", "123456", "hello1", "snuffles", "emma2003"]
strong_pws = ["GgbvTa581!@", "@Mjrc0olguy!", "007jmSB0nd!", "108turt!es762", "Avv3SoMe!305"]
all_pws = strong_pws + weak_pws
password = codesters.Text("password")
def interval():
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, 3)
def click(sprite):
global score
pw_text = password.get_text()
if pw_text in weak_pws:
score -= 1
password.event_click(click)
t = codesters.Teacher()
update = t.find_function('update')
try:
tval1 = update[0][1]
tval2 = t.get_indent_at_line(update[0][0])
except:
tval1 = "DNE"
tval2 = "DNE"
#print tval1, tval2
t1 = TestObjective()
t1.add_success('score_board' and '(score)' in tval1 and tval2 == 8, "Great job!")
t1.add_failure(tval1 == "DNE", "Did you add an Update Display command?")
t1.add_failure('score_board.' not in tval1, "Did you change the name in front of your update command to score_board?")
t1.add_failure('(score)' not in tval1, "Did you change the variable inside the Update Display command to score?")
t1.add_failure(tval2 < 8, "Make sure you indent your Update Display command inside your if statement.")
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)