The best way to crack the Caesar Cipher is to look at letter frequency with the letter "E" which should be the most frequent letter in any string of text and this allowing users to work out what offset is used for encoding and decoding.
We have just been doing conditionals (IF statements) in Python with my Year 10 students and I thought this was a wonderful opportunity to create a letter frequency counter around the same generalised code (with some minor changes).
The first thing to deal with is to set up all the variables (one variable each to count the letter frequency for each individual letter of the alphabet)
Some points to highlight with students:
- This is a simple input / process / output program
- Python is case sensitive so there is a need to convert inoutted strings to either upper or lower case and then count the string
- By changing the IFs to ELIFS you can really highlight the difference in the way that these two conditionals function and affect the flow of a program
- There are much better ways to process the data search / count using a list or tuple to cycle through each letter in the alphabet
For other coding and teaching ideas click here.
I am sorry I had to compress the file as a zip file simply due to the fact that the blog would not allow me to attach .py files!