As usual, write in your diary as you do the following exercises. TeX submission required.
Test your function by calling it on a letter frequency table for a text, to convert counts to fractions.
Write a Python function that accepts a list (or other iterable) of key-value pairs where the value is numeric. The program should create a histogram of the data.What I should have asked for:Test your function. Paste the graphic into your TeX document.
Create a bar chart from data in a Python list (or other iterable) of key-value pairs where the value is numeric.What's the difference? The second specification just asks for the result, without telling you how to do it. When I googled for bar charts in Python I found stackoverflow.com/questions/11617719/how-to-plot-a-very-simple-bar-chart-python-matplotlib-using-input-txt-file. The first answer there does tell you how to draw a bar chart using Python. It's not easy. The second answer says "use Excel". The purpose of this course is to help you find and use the software tools that help with mathematics. Excel is one such. Use it here.Test your method. Paste the graphic into your TeX document.
You can prepare input for Excel by asking Python to write a
.csv
file, or by cutting output from the window running Python
and pasting it into such a file.
For encoding the permutation will mix up the whole alphabet. For decoding you'll want to see what the text looks like with a partial replacement - perhaps changing the most frequent letter to an e. In that case you might want to have the output an upper case E so you can see which letters you've tried to guess so far.
Write and test the Python function
def scramble( input, output, permutation, encode=True ): """ input is a text file (maybe with spaces and punctuation), output is a text file with some letters replaced by lookup in the permutation dictionary. If encode==True then output should be all lower case. If encode==False then input should be converted to lower case and output transformed letters should be upper case."""