← Back to Library
Lesson PlanFreeEN

CyberPi: Data Protection and Passwords

In this lesson, students will explore the topic of data security and create a digital artifact to demonstrate how a password-protected security device can protect personal data. Students will need to describe commonly used data security measures and when to use them. Based on real-life scenarios, students should explain the importance of data security measures. Students will also explore how to use physical security devices to verify and confirm information.

Gr. 9–10
CyberPi: Data Protection and Passwords

Lesson

Overview

Description

In this lesson, students will explore the topic of data security and create a digital artifact to demonstrate how a password-protected security device can protect personal data. Students will need to describe commonly used data security measures and when to use them. Based on real-life scenarios, students should explain the importance of data security measures. Students will also explore how to use physical security devices to verify and confirm information.

Objectives

  • Using variables to transmit data between computer and CyberPi

  • Displaying text and information onto the CyberPi screen

  • Importance of data security and password protection

Before the Lesson

Preparation

For the teacher

  • Students should have a laptop or device with mBlock 5 installed from here: https://www.mblock.cc/en/download/ (desktop version or cloud-based version) and mBlock Python editor (mLink) installed. Click here to download the Python editor (mLink)

  • One CyberPi with USB-C cable 

  • Pocket shield (optional)

  • Worksheet: Lesson 10 Data Protection and Passwords

  • Example Program: Lesson 10 Data Protection and Passwords

  • Refer to the text-based beginner lessons in this bundle for more ways to teach text-based programming without the use of the CyberPi.

Introduction

  • In this lesson students will explore the topic of data security and create a digital artifact to demonstrate how a password-protected security device can protect personal data.

  • Students need to describe commonly used data security measures and when to use them.

  • Based on real-life scenarios, students should explain the importance of data security measures.

  • Students will also explore how to use physical security devices to verify and confirm information.

Review

Warm Up

1. Let's begin by familiarizing ourselves with the key points of this lesson:

  • Explain common security measures to protect personal data and information with real-life examples

  • Explain how to create a password and verify the password through a password-protected security device

  • Write and execute algorithms to simulate how a password-protected security device protects personal data

2. Discuss the essence of password-protected security measures.

  • Ask: When do you use passwords?

  • Have students share their experience of using passwords and explain why they use them.

  • Summarize students' discussion and list some of the common situations that people use passwords to protect their data and privacy (for example, sign into a Google account, unlock a mobile phone, withdraw money, make a payment, etc.).

  • Ask: What if we do not have passwords in these situations, what may happen? What kinds of problems would you have?

  • Have students discuss the safety of passwords and real-life examples.

3. Have students fill out the ‘What I Know’ column of the K-W-L chart before the class.

Direct Instruction

Tour of mBlock 5

1. Open the mBlock software or mBlock 5 Web version.

2. Introduce students to the following key areas of the software interface:

Connect the CyberPi

3. Plug the CyberPi into the computer using the included cable. The CyberPi should boot up and the screen will display either the last program uploaded or the Home menu.

4. On the "Devices" tab in mBlock, click the "Add" button. Select CyberPi and click "Ok".

5. Click the "Connect" button. Then, select the USB port and click "Connect".

6. If connected successfully, the button will change to "Disconnect".

7. When you open the editor for the first time you will see these explanations mapping the interface. Encourage students to thoroughly read through it. Below are the screen captures if you ever need to reference them again.

Figure 1: To connect your CyperPi

Figure 2: Creating Projects and Project files (see How to Create, Open, Import, or Export Project Files)

Figure 3: Editing Area

Figure 4: Console Commands to run code and more

Figure 5: Terminal (Console) to display output from Editing Area

Figure 6: Libraries containing example program. Feel free to explore these at your leisure

Figure 7: Click "Tutorials" to view these helpful instructions anytime

Guided Practice

Hands On

Activity 1:

1. Have students read "Activity 1" in the example program

  • Say: The example program is to demonstrate how to create and verify a password through a physical password-protected security device.

2. Ask students to think about the questions below:

  • How to create a password for a new account?

  • How to verify the password entered by a user?

  • Compare the two ‘while’ loops used in the example program. What is the difference between them?

  • Identify the syntax that enables the following function: A user is given 3 attempts to enter the account password. If the user has 3 failed attempts, the user is blocked from entering the password a 4th time.

3. Explain how the example program works.

  • Explain: The user needs to type the password twice and the variables 'pin_1' and 'pin_2' store the password input. The expression ‘if pin_1 == pin_2 ' is to confirm whether the two passwords match each other.

  • Have students think about why the user should type the password two times.

  • Remind students of the use of the ‘break’ function in the ‘while’ loop.

4. Have students explain the functions and logic behind the code in their own words.

  • Have students think about the similarity between the function of creating a password and the function of verifying the password.

  • Have students compare the two ‘while’ loops and figure out the difference.

  • Students should identify and explain how to lock the account after 3 unsuccessful sign-in attempts.

  • Possible Answer: 

The ‘while True’ is to create an indefinite iteration, which means that on specified times the loop is executed and isn’t specified on request. In short, the ‘while True’ functions as a forever loop.

The ‘while <controlling expression> (is True)’ (e.g. ‘while t < 3:’)’ function has a controlling expression as the specified condition for iteration, the loop is executed if the controlling expression is verified as ‘True’. In the example program, the user has three attempts to type the password to sign into the account, and therefore, the controlling expression is ‘t < 3’.

5. Ask students to explain the program and draw a flowchart.

Independent Practice

Try It!

Activity 2:

  • Have students work in pairs or individually to complete the following tasks:

  • Note: solutions for these tasks are contained the example program

Task 1: Add a function that allows the user to create a username when the user signs in.

Task 2: Add some lighting effects as the indicator. Use what you have learned to program CyberPi.

API code samples of the LED strip:

cyberpi.led.on(255, 255, 255)

cyberpi.led.on(“green”, id = “all”)

cyberpi.led.on(“red”, id = 3)

cyberpi.led.show(“orange yellow cyan blue purple”)

cyberpi.led.play(name = “firefly”)

cyberpi.led.off(id = “3”)

Task 3: Modify the second ‘while’ loop. Use the LEDs as an indicator to visualize the number of attempts. (Note: The user has 5 login attempts.)

Task 4: Modify the conditional expressions. Verify the following three conditions:

The input username is incorrect;

The input password is incorrect;

Both the username and password are incorrect.

Activity 3:

1. Ask students to develop a bank card reader based on the structure and logic of the example program.

2. Explain what a card reader is: A card reader is a security device. When your parents want to make a payment through their bank accounts, they will be asked to use the card reader as a security measure. For example, they need to enter the PIN with the keypad on the card reader and will receive a random verification code or passcode number to confirm the transaction.

3. Explain how the card reader project functions and list the requirements of the project:

  • Like the example program, first create a PIN for the bank account and store it on the computer.

  • When a sender starts a transaction, ask the sender to type the name (or other identification code) of the receiver and the amount of the transit money.

  • Then ask the sender to type the PIN.

  • Generate a random 4-digit verification code and display it on CyberPi’s screen. Ask the sender to enter the verification code.

  • Check the PIN and verification code. If both are correct, display the transaction information (including the receiver’s name or ID and the transaction amount) on the screen.

  • However, if either the PIN, the verification code or both are incorrect, ask the sender to type them again. The sender has limited attempts (for example, 3 attempts).

  • Ask the sender to check the transaction information and confirm the transaction by pressing Button B of CyberPi.

4. Demonstrate the program below to show how to create a 4-digit verification code and display it on CyberPi’s screen.

5. Provide the part of code below for reference. Students should consider where to insert the lines of code in the card reader program.

  • The above script is to confirm the transaction information displayed on the screen. The sender should check the receiver and the transfer amount and then confirm the transaction if everything is correct.

  • Have student annotate this part of code either in the Python editor or on the worksheet.

Reflection:

  • Have students fill out the K-W-L chart

  • Remind students to always comment their code, regardless of the simplicity

Extension:

  • Allow students to expand their application by implementing an ATM.

  • After they create their account allow the user should add money to their account

  • The user should be able to take money out and add as they like but must input their pin before every transaction.

Wrap Up

Wrap-Up & Quick Check

Summary:

1. The importance of data security and how programs can add a level of protection

2. Communication via transmitting data between CyperPi and the computer

Downloadable Material

Example Program

Worksheet

Educational Standards

Ontario - Grade 9-10 - Mathematics & Computer Science

Grade 9

Math (Coding)

  • Coming Soon!

Grade 10

Computer Science

B1: ICS20 Arithmetic Operations 

  • B1.1 use correct terminology to describe programming concepts; 

  • B1.2 describe the types of data that computers can process and store 

  • B1.4 determine the expressions and instructions to use in a programming statement, taking into account the order of operations

  • B1.5 identify situations in which decision and looping structures are required;

  • B1.6 describe the function of Boolean operators 

B2: Writing Programs

  • B2.1 use a visual problem-solving model to plan the content of a program;

  • B2.2 use variables, expressions, and assignment statements to store and manipulate numbers and text in a program 

  • B2.3 write keyboard input and screen output statements that conform to program specifications;

  • B2.4 write a program that includes a decision structure for two or more choices

  • B2.5 write programs that use looping structures effectively 

B3: Code Maintenance

  • B3.1 write clear and maintainable code using proper programming standards

  • B3.3 use a tracing technique to understand program flow and to identify and correct logic and run-time errors in a computer program;

  • B3.4 demonstrate the ability to validate a computer program using test cases.