SPIKE™ Prime with Python

Password Protection

Create a password using bricks to explore security measures

45 min
Years 7-9 or Key Stage 3

Questions to investigate

• How can you create secure passwords?


• Each student will need 5 colors of 2x4 bricks from the SPIKE Prime Set.
• Ensure SPIKE Prime hubs are charged especially if connecting through Bluetooth.


(Group Discussion, 5 minutes)

Ignite a discussion around locks. Where do we use a lock? Why do we use a lock?

Explain to students that sometimes people use a lock when they want to keep something safe. Ask students the following questions:
• What is a password?
• Where do we use passwords?
• How can a strong password keep our information safe?
• Why do we not share our passwords?

Allow students to share examples of passwords reminding them to not share any actual passwords.


(Small Groups, 20 minutes)

Students will investigate creating more secure passwords.

Ask students to select 5 different colors of 2x4 bricks from their set.

Working in pairs, assign each team a Partner A and a Partner B. Partner A should write 3 numbers in his/her journal without Partner B seeing what they are writing. Partner B should guess the first number written. Partner A sees how many guesses it takes and writes the number of guesses underneath the guessed number. Repeat for the second and third number.

Switch roles. Partner B writes 3 numbers in his/her journal. Partner A guesses the numbers and then Partner B writes how many guesses it takes.

Discuss the outcomes together as a class. Ask students how many possible answers were there for each number. 10 possible answers– 0,1,2,3,4,5,6,7,8,9. How many possible answers are there for a 3-digit passcode? (10 x 10 x 10) [numbers 000 to 999]

Discuss together how you could make the password even more secure. Students should recognize that adding another number to make a four-digit password will be more secure (and more so with each number added).

Brick Password
Challenge students to create a brick-based password by creating a 5 step password using their bricks.

Each partner should create a password by first creating a stack of bricks with the first step of the password or first color being at the bottom of the stack and the last at the top of the stack. Students can make the stack in any order they want.


(Whole Group, 5 minutes)

Discuss with students how their passwords worked.
Ask students questions like:
• Which password was more difficult to guess, the 3-digit number or the 5-brick password?
• What made guessing the last few colors of the brick password easier?
• What could you do to make the password even stronger?


(Small Groups, 10 minutes)

Challenge students to come up with a more secure password.

Ask students to remove the hub from their SPIKE Prime set. Challenge students to create a password and indicate if the password is correct or not on the hub using images, words, or sounds.

Direct students to open a new project in the Python programming canvas. Ask students to erase any code that is already in the programming area. Students should connect their hub.  

Brainstorm ideas for using the hub to create a password. Ideas might include setting the motion sensor orientation to a certain position (like up, forward, left), using the motion sensor gestures (like shake or tap), or pressing one of the buttons. Students might then think about showing a smiley face if the password is correct or print good job on the hub.

Ask students to write a pseudocode for how they plan to use the hub as part of their password. Students should then create their program according to the pseudocode. Remind students to use code comments in the program to indicate what should happen. Students should also watch the console for error messages as they create their program.


(Group Exercise, 5 minutes)

Teacher Observation:
Discuss the program with students.
Ask students questions like:
• What happened when you made your passwords more difficult?
• Why do we use passwords?
• How can you create a physical password?

Have students answer the following in their journals:
• What did you learn today about using passwords?
• What characteristics of a good teammate did I display today?
• Ask students to rate themselves on a scale of 1-3, on their time management today.
• Ask students to rate themselves on a scale of 1-3, on their materials (parts) management today.

Teacher Support

Students will:
• Investigate cyber security through setting passwords
• Explore physical security measures

• SPIKE Prime sets ready for student use
• Device with the SPIKE App installed.
• Student journals

2-CS-02 Design projects that combine hardware and software components to collect and exchange data.
2-NI-05 Explain how physical and digital security measures protect electronic information.
2-AP-13 Decompose problems and subproblems into parts to facilitate the design, implementation, and review of programs.
2-AP-16 Incorporate existing code, media, and libraries into original programs, and give attribution.
2-AP-19 Document programs in order to make them easier to follow, test, and debug.