Skip Navigation

Code Words with Python

By Bilal Qadar 120 minutes
Level
Grades 9-12
Subjects
Science and Technology,
Social Sciences
components
  • Programming
  • Computing and Networks
  • Technology and Society
Tools & Languages
Python

Key Coding Concepts

  • Algorithms
  • Arrays
  • Variables

Terminology

Brute Force Attack

A computer strings random characters and numbers together to guess a password. A computer can perform thousands of guesses a second.

 

Dictionary Attack

A computer tries random common words and phrases strung together to guess a password. This is usually much faster than a brute force attack because the guesses are less random.

Why is having a strong password important? Strong passwords help protect your information and identity. As phishing and social hacking become quite common, we need a way to generate secure passwords that we can still remember!

Developed in partnership with:
This is a Canada Learning Code Week lesson plan! Once you’ve taught at least one of our lesson plans, share your impact with us: https://bit.ly/clc-impact

Technology
  • WiFi-enabled laptops, computers or notebooks

Before the lesson...
  • Review lesson plan
  • Optionally review Intro to Computer Science slides to familiarize yourself with Python
  • Review key coding concepts and ensure you are confident describing them to your group
  • Review the solution sheet depending on the age range of the audience
  • Code/build the lesson’s main project, ensuring you are comfortable with all steps
  • Print any learner resources
  • Locate and gather technology + additional materials

Introduction

Ask: Has anyone received an email or phone call that sounds something like this?

“From: school123@gmail.com

Dear user, this email is to inform you that your student account has been compromised. Please click the link below and enter your password to secure your account. Thanks, School Safety Squad”

Raise your hand if you think this email sounds authentic.

This email is an example of phishing! Phishing are web pages designed to look identical to trusted websites on the internet. The goal of a phishing website is to have you enter your username and passwords so an individual can store them with evil-minded intent.

Although phishing is common there are other ways illegitimate organizations or individuals try and obtain your password.

Do: Write these passwords in a space where all learners can see:

  • Refrigerating
  • 13579
  • H4CK3R
  • W3lc0m3!

THINK + PAIR + SHARE: Take a look at these passwords. Rank them from most secure to least secure. Once complete try and modify the unsecured passwords to make them secure!

Run this python program to see how many seconds it takes a computer to get these passwords. This program uses brute force and dictionary attacks to guess your password.

Ask: Did the results match with the way you ranked your passwords?
Ask: What does a brute force attack mean? (A: A computer tries random combinations of characters until it guesses the password)
Ask: What does a dictionary attack mean? Think about what you use an English dictionary for? (A: A computer tries guesses of commonly used phrases and words stringed together)
Ask: Why was “W3lc0m3!” not able to be guessed? (A: It had a combination of upper and lower case letters, numbers and special characters!)

Let’s create some safe passwords that we can remember!

Code-Along

Note: Remind learners not to share any information or elements of their current passwords in the next activity.

Ask: What is code? (A: A set of instructions read and performed by a computer)

Optionally: Perform the Do the Robot unplugged activity.

Perform Code-Along according to the age of learners. Follow the appropriate solution sheet linked below:

Learning Outcomes
  • I can create algorithms in Python
  • I can test, experiment, and refine my code when solving a problem
  • I can develop solutions to real life problems computationally
  • I can use variables and arrays (lists) to store data
  • [Ages 13+] I can use loops to repeat instructions in code
  • [Ages 13+] I can use conditional statements to make decisions using code
  • I can define cybersecurity and create safe passwords using effective criteria

Assessment Ideas

Encourage learners to modify their projects to generate/remix usernames and passwords. Have learners demonstrate key programming concepts from their project including:

  • Variables
  • Arrays (lists)
  • Python Random functions
  • [Ages 13+] Conditional Statements

Ask learners to complete an exit slip at the end of the session. Ditch That Textbook has an excellent template you may use. We've added a few instructions related to this lesson in the notes section.

Online Extensions

Perform add-on activities in solution sheets.

Learners with Python experience can take a look into the python password guessing source code.

Learners can add print outs and tinker with the code to make it able to guess all kinds of passwords. Furthermore, learners can research ethical hacking and why creating a password guessing program can actually help patch vulnerabilities!

Unplugged Extensions

Optional: Learners can go through the “Introduction to Computer Science” slides. Have them reflect on how they used components in the slides in their projects. ie) How did we use variables in our project?

Robotics Challenge

Bring real-world industry to your classroom! In this free, three-hour virtual learning experience, students learn the basics of computer science while uncovering the miraculous ways goods are delivered at Amazon. Sign up for the Amazon Cyber Robotics Challenge here.

Unplugged activity inspired by “Creating Strong Passwords” lesson created by Diana Arruda for Pinnguaq

Photo by Logan Kirschner from Pexels

20 ideas for exit tickets in the classroom (Ditch That Textbook)
https://ditchthattextbook.com/10-ideas-for-digital-exit-tickets-and-some-analog-ones-too/

Teach lessons that are tied to your existing curriculum! https://bit.ly/CLClessons

r

More Lesson Plans For Grades 9-12

    View All Lesson Plans

    Explore lessons based on components

    The K-12 Computer Science Framework

    Although learning how to build digital projects is a key part of Computer Science education, students should also learn a wider set of skills and competencies that will help them to harness the power of digital technologies as both creators and consumers. A comprehensive approach to K-12 Computer Science education includes learning about the following five focus areas:

    View Framework ➝

    Programming

    By the end of high school, students should be able to create a simple computer program.

    Computing and Networks

    By the end of high school, students should understand and be able to use the tools and devices commonly used to build digital projects.

    Data

    By the end of high school, students should be able to explain how we use computers to create, store, organize, and analyze data.

    Technology and Society

    By the end of high school, students should be able to explore the ways in which technology and society have mutually shaped each other.

    Design

    By the end of high school, students should be able to apply design principles to the digital projects they create.