Some simple codemaking and codebreaking examples using Python.
This is a series of Python script that introduce basic concepts in Python such as input, output, loops, decisions and using modules. The series finishes with an implentation of a substitution cypher (Ceaser's Cypher) and a brute-force decode function to show an example of how codes are broken.
-
Input and Output ============================ This is the foundation of human computer interaction. We tell the computer what to do via input. The computers shows us the result of what it does via outputs.
-
Get the students to type in the code from input.py
-
Explain what each line of the code is for and run the progr am to demonstrate how this works.
-
Change the last print line and run to check your response works.
-
Choices ============================ We will see how computers make decisions based on the different inputs we make.
-
Type in the code from choice.py
-
Recap the function of inputs and outputs and introduce the if process and language related to this.
-
Run the program and explore how different answers receive varied respomses.
-
Edit the code to alter the responses to questions and change the values required to elicit the response.
-
Add new responses using the code modelled. Test.
-
Encode ============================
-
Model Caesar cypher or substitution cypher using pen and paper.
-
Enter the code from encode.py
-
Explain how this recreates the Caesar cypher using python. Point out how the alphabet is chopped up and asigned an offset number. 4.Run the code and enter a word and decode using a paper cypher to check it is correct.
-
Code Breaking =============================
-
Explain how Brute force coding works, checking every possible answer to find a suitable response.
-
Try this by hand first using a paper cypher for a simple word, find a word that makes sense. This will model the labourious process of code breaking.
-
Enter the code from caesar.py
-
Explain the lines fo code that show the loops and functions, that remove the need to run this function 26 times.
-
Run the code, search the responses and has your coded word been decoded in one of the responses.
-
Children to create a coded phrase and ask the childre to decode this to break the code using the program.