INSTRUCTIONS:

  • Follow the instructions on the stage to complete this interactive learning activity.
  • Look out for key terms marked with a ★!
  • Sometimes you will have to complete a task on the stage to continue. Pay attention!
  • At the end of the activity click Submit and Next to move on!

To navigate the page using the TAB key, first press ESC to exit the code editor.

import codesters import random from codesters.demo import Demo from codesters import Text # Set constants stage_height = float(stage.get_stage_height()) stage_width = float(stage.get_stage_width()) offstage_below = -1000 # Use as y value to create objects below the stage wait_time = 1 # Create Demo instance demo = Demo() # Set up stage stage.auto_cache_off() stage.set_background_color("black") stage.disable_floor() chars = [] for counter in range(60): x = random.randint(-550, 550) binary = codesters.Text(chr(random.randint(33, 255)), x, 300, "green") binary.set_y_speed(random.randint(-3, -1)) binary.set_physics_on() binary.set_opacity(random.random()) chars.append(binary) def interval(): for char in chars: if char.get_y() <= -(stage_height/2): char.go_to(random.randint(-550, 550), 310) char.set_y_speed(random.randint(-3, -1)) char.set_opacity(random.randint(1,10)/10) stage.event_interval(interval, 0.05) lesson_title = Text("Cybersecurity: Introduction", 0, 200, "white") lesson_title.set_text_width(800) lesson_title.set_text_size(40) activity_title = Text("What is a system? Part 2", 0, 150, "white") activity_title.set_text_width(600) activity_title.set_text_size(30) stage.wait(wait_time*1) guide = demo.create_sprite_off_screen("person20", -stage_width/2-50, -150, 1) guide.glide_to(0, -150) guide.say("Welcome back!\nClick Next to continue learning about systems and security.", 0, "white", 18) stage.wait(wait_time*3) demo.continue_action() guide.say("") lesson_title.set_speed(10) lesson_title.glide_to(0, 1000) activity_title.set_speed(10) activity_title.glide_to(0, 1000) demo.remove_all_sprites_except([guide]+chars) def time_for_test(question, correct_answer, wrong_answer, feedback, other_feedback): guide.say("Let's think about systems!") stage.wait(1.5) student_input = guide.ask(question).lower().replace(" ", "") while student_input != correct_answer: guide.say("Hm... Try again!") stage.wait(1) guide.say(feedback) stage.wait(1) if student_input == wrong_answer: guide.say("Hm... Try again!") stage.wait(1) elif student_input == other_value: guide.say(other_feedback) stage.wait(1.5) else: guide.say(feedback) stage.wait(1.5) student_input = guide.ask(question).lower().replace(" ", "") def stage_blank(): demo.remove_all_sprites_except(keep_stage_elements+chars) guide.say("") for element in keep_stage_elements: element.hide() for char in chars: char.hide() char.set_y_speed(0) stage.event_interval(None) def stage_reset(): global street_click, swim_click, lock_click demo.remove_all_sprites_except(keep_stage_elements + chars) stage.set_background_color("black") for element in keep_stage_elements: element.show() guide.say("Click a red box to see a safety rule in action!", 0, "white", 20) keep_stage_elements[7].hide() keep_stage_elements[9].hide() keep_stage_elements[11].hide() for char in chars: char.show() char.set_y_speed(random.randint(-3, -1)) stage.event_interval(interval, .05) if street_click: keep_stage_elements[7].show() if swim_click: keep_stage_elements[9].show() if lock_click: keep_stage_elements[11].show() if street_click and swim_click and lock_click: guide.say("") demo.unpause() def lock_up(): global lock_click lock_click = True stage_blank() stage.set_background_color("thistle") door_outline = codesters.Rectangle(240, -25, stage_width/4+50, stage_height-50, "black") door = codesters.Rectangle(240, -37.5, stage_width/4, stage_height-75, "#964B00") door_knob_outline = codesters.Circle(340, -45, 50, "black") door_knob = codesters.Circle(340, -40, 45, "silver") window_outline = codesters.Square(-285, 118, stage_width/4, "black") night_1 = codesters.Square(-285-(65), 118+65, 110, "blue") night_2 = codesters.Square(-285+(65), 118+65, 110, "blue") night_3 = codesters.Square(-285-(65), 118-65, 110, "blue") night_4 = codesters.Square(-285+(65), 118-65, 110, "blue") rule_text = codesters.Text("Safety System Rule: Lock windows and door at night", 0, (stage_height/2)-50, "white", "red") rule_text.set_text_width(700) rule_text.set_text_size(28) sprite = demo.create_sprite_off_screen("person7", -500, -90, 1.75) sprite.move_forward(150) sprite.set_say_position(0, -100, "relative") sprite.say("Locked!", 2, "red", 20, "impact") sprite.move_forward(600) sprite.say("Locked!", 2, "red", 20, "impact") sprite.move_forward(350) stage_reset() # should i re-introduce cyberesecurity definition here? guide.say("We have defined cybersecurity as the art\nof building secure computer systems...", 0, "white", 20) stage.wait(wait_time*2) text = u"★" + " Cybersecurity is all about building secure computer systems that we can trust! " systems_def = demo.animate_typing_text(text, -stage_width/3-100, 225, align="left", font_size=25, color = "white", cursor_wait = False) stage.wait(wait_time*2) guide.set_say_width(600) guide.say("And we have defined a system as a group of related parts that affect each other and work together as a whole...", 0, "white", 20) stage.wait(wait_time*2) text = u"★" + " A system is a group of parts that work together as a whole " systems_def = demo.animate_typing_text(text, -stage_width/3-100, 190, align="left", font_size=25, color = "white", cursor_wait = False) stage.wait(wait_time*1) demo.continue_action() guide.say("We have looked at a\nbike and a computer\nas examples of a system.", 0, "white", 20) stage.wait(wait_time*2) demo.continue_action() guide.say("Our systems definition also applies to rules or procedures and how they work together to support a specific outcome.", 0, "white", 20) stage.wait(wait_time*3) demo.continue_action() demo.remove_all_sprites_except([guide]+chars) guide.say("") guide_text = codesters.Text("Our systems definition also applies to rules or procedures\nand how they work together to support a specific outcome.", 0, 150) guide_text.set_text_size(20) guide_text.set_text_width(800) guide_text.set_text_background("silver", "white", 0.85) guide_text_2 = codesters.Text("Let's begin with an example from your own life!", 0, 75) guide_text_2.set_text_size(20) guide_text_2.set_text_background("silver", "white", 0.85) demo.continue_action() keep_stage_elements = [systems_def, guide, guide_text, guide_text_2] demo.remove_all_sprites_except(keep_stage_elements+chars) guide.say("") guide_text_2.hide() guide_text.set_text("You have a set of rules (a system) for keeping yourself safe:") guide_text.set_y(175) stage.wait(wait_time*2) guide_text_2.set_y(100) guide_text_2.set_text_width(800) guide_text_2.set_text("For example,\nyou look both ways before crossing a street,\nyou don't swim without a lifeguard,\nand you lock up at night!") guide_text_2.show() stage.wait(wait_time*1) system2 = demo.create_sprite_off_screen("clipboard_096", -325, -175, 1) clipboard_cover = codesters.Rectangle(-280, -185, 70, 185, "white") clipboard_cover.set_rotation(15) keep_stage_elements += [system2, clipboard_cover] clickables = [] y = -137 x = -300 for counter in range(3): box = codesters.Square(x, y, 45, None, "red") box.set_line_thickness(5) box.set_rotation(15) check = demo.create_sprite_off_screen("green_check", x+10, y+7, .3) check.hide() rule_overlay = codesters.Square(box.get_x(), box.get_y(), 50, "white") rule_overlay.set_opacity(.01) keep_stage_elements.append(box) keep_stage_elements.append(check) clickables.append(rule_overlay) y -= 57 x += 16 keep_stage_elements += clickables def cross_street(): global street_click street_click = True stage_blank() stage.set_background_color("black") top_sidewalk = codesters.Rectangle(0, -stage_height/2+50, stage_width, 100, "lightgrey") bottom_sidewalk = codesters.Rectangle(0, stage_height/2-50, stage_width, 100, "lightgrey") rule_text = codesters.Text("Safety System Rule: Look both ways before crossing", 0, (stage_height/2)-50, "navy", "white") rule_text.set_text_width(700) rule_text.set_text_size(28) x = -stage_width/2 for counter in range(7): dashes = codesters.Rectangle(x, 0, stage_width/7, 20, "white") x += stage_width/7+60 car = demo.create_sprite_off_screen("car1", -stage_width/2-125, -110, 1.5) car.set_rotation(-90) car.set_speed(10) crosser = demo.create_sprite_off_screen("person2", -375, -210, 1) crosser.say("Car's coming!", 1, "orange") crosser.flip_right_left() stage.wait(1) crosser.flip_right_left() stage.wait(1) car.move_right(stage_width) stage.remove_sprite(car) crosser.move_up(stage_height-210/2) stage.wait(2) stage_reset() def swim_safe(): global swim_click swim_click = True stage_blank() beach = demo.create_sprite_off_screen("lifeguard_a68", 0, 0, 3) rule_text = codesters.Text("Safety System Rule: Swim with a lifeguard", 0, (stage_height/2)-50, "white", "red") rule_text.set_text_width(700) rule_text.set_text_size(28) swimmer = demo.create_sprite_off_screen("scubadiver2", -300, -200, 1) swimmer.set_say_position(0 , -50, "relative") swimmer.set_say_background("black", 1) swimmer.say("There's a lifeguard on duty! I can swim!", 3.5, "aqua", 20, "verdana") coords_list = [(-303, -97), (-283, -59), (-245, -28), (-190, -5), (-141, 5), (-102, 6), (-78, 7), (-65, 7), (-61, 6), (-61, 6)] size = 1 rotation = -15 swimmer.set_speed(5) for coords in coords_list: swimmer.glide_to(coords[0], coords[1]) swimmer.set_rotation(rotation) swimmer.set_size(size) size -= .1 rotation -= 15 stage.wait(1) stage_reset() street_click, swim_click, lock_click = False, False, False guide.set_say_position(-300, 15, "fixed") guide.say("Click a red box to see a safety rule in action!", 0, "white", 20) clickables[0].event_click(cross_street) clickables[1].event_click(swim_safe) clickables[2].event_click(lock_up) demo.pause() stage.wait(2) demo.continue_action() demo.remove_all_sprites_except(keep_stage_elements+chars) guide_text.set_text("These rules are part of a system that keep you safe.") guide_text_2.hide() stage.wait(wait_time*1) keep_stage_elements = [systems_def, guide, guide_text, guide_text_2] systems_def.show() guide_text_2.set_text("You are surrounded by systems every day!") guide_text_2.show() stage.wait(wait_time*2) demo.continue_action() guide.hide() guide_text.hide() guide_text_2.hide() demo.remove_all_sprites_except(keep_stage_elements) stage.set_background("park") stage.set_background_x(-550) stage.set_background_y(750) stage.set_background_scale(2.2) sprite = demo.create_sprite_off_screen("person6", 0, -100, 1.5) sprite.set_say_background("white", 1) sprite.set_say_width(580) bike = demo.create_sprite_off_screen("bike", -700, -190, 2) bike.glide_to(-325, -190) sprite.say(" Systems thinkers look at systems and think about how all the parts interact. \n") stage.wait(wait_time*2) sprite.say(" Systems thinkers look at systems and think about how all the parts interact. \nThey think about what goes into the system and what comes out of the system, and how that impacts the system as a whole!") stage.wait(wait_time*3) demo.continue_action() sprite.say("") thought_bubble = demo.create_sprite_off_screen("thought_bubble_14e", 225, 150, 1.3) bubble_text = codesters.Text("Hmmm...\nhow can I change the bike system?", 230, 170) stage.wait(wait_time*3) demo.continue_action() bubble_text.set_y(160) bubble_text.set_text("I can oil the chain to make\nthe bike go more smoothly!") stage.wait(wait_time*3) thought_bubble_b = demo.create_sprite_off_screen("thought_bubble_b_969", 235, -150, 1.2) thought_bubble_b.flip_up_down() bubble_text_b = codesters.Text("Or I could add springs to\nmake the bike more stable!", 240, -170) stage.wait(wait_time*3) demo.continue_action() bubble_text_b.hide() thought_bubble_b.hide() thought_bubble.hide() bubble_text.hide() thought_bubble.flip_right_left() thought_bubble.set_x(-235) bubble_text.set_x(-225) bubble_text.set_text("But what if I wanted to\nDISRUPT\nthe bike system?") thought_bubble.show() bubble_text.show() stage.wait(wait_time*3) demo.continue_action() bubble_text.set_text("I could put a stick\nthrough the wheel's spokes!") stage.wait(wait_time*2) bubble_text_b.set_text("Or I could take off the chain!") bubble_text_b.show() thought_bubble_b.show() stage.wait(wait_time*2) demo.continue_action() demo.remove_all_sprites_except([systems_def, guide_text, guide_text_2]) systems_def.hide() stage.set_background("cyber_blue") guide_text.set_text("In order to study and change a system, we need to know the parts of the system...\n") guide_text.show() stage.wait(wait_time*3) guide_text.set_text("In order to study and change a system, we need to know the parts of the system...\nhow they interact, and the results they produce!") stage.wait(wait_time*3) guide_text_2.set_text("To learn about cybersecurity,\n\n") guide_text_2.show() stage.wait(wait_time*1) guide_text_2.set_text("To learn about cybersecurity,\nwe need to know about the parts of the cybersecurity system!\n") stage.wait(wait_time*2) guide_text_2.set_text("To learn about cybersecurity,\nwe need to know about the parts of the cybersecurity system!\nClick Submit and Continue to continue learning more about systems and cybersecurity!") stage.wait(wait_time*1) sprite_list = demo.remind_student_to_submit(guide_text_2.get_x() - 175, guide_text_2.get_y() - 100, 25) tester = TestManager() tester.display_success_message("Great job!")
  • Run Code
  • Submit Work
  • Next Activity
  • Show Console
  • Reset Code Editor
  • Codesters How To (opens in a new tab)