Exercise 1

Write a function that takes in 1 number x and prints out a x by x times table nicely formatted, for example if i called f(x) i'd get

  | 1   2   3   4   5
=====================
1 | 1   2   3   4   5
2 | 2   4   6   8  10
3 | 3   6   9  12  15
4 | 4   8  12  16  20
5 | 5  10  15  20  25
      
You can assume the highest number you'll get is 99

Exercise 2

Write a function that takes in a list of tuples where each tuple contains a fruit, it's cost and the selling price of the fruit

Calculate the optimal set of fruits to buy which will maximise your profits BUT you can't buy more then n fruits because that's all the space you have in your store, i.e write a function f(fruits, max) which returns the set of fruits to buy

fruits = []
fruits.append(("apple",12,5))   # an apple worth 12 bucks with a selling price of 5 bucks
fruits.append(("bannana",3,100)
l = f(fruits,1) # l is ["bannana"] which is the most profitable
    

Exercise 3

Write a function that takes in a movie title such as "need for speed" and generates every possible play on the title that involves changing 1 character, such as "seed for speed" or "need far speed", but to narrow down the amount of results that are garbage like 'xeed for speed', don't replace any letter with "x" "y" or "z".

l = f("need for speed")
print(l) # ["seed for speed",...]
    

Exercise 4

Write a function that given a file name will read the file and print out how often each letter is used as a percentage (case insensitve)

count_letters("hello.txt") # assume hello.txt is a file with 1 line in it "HHH"
a : 0.00%
b : 0.00%
c : 0.00%
d : 0.00%
e : 0.00%
f : 0.00%
g : 0.00%
h : 100.00%
i : 0.00%
j : 0.00%
k : 0.00%
l : 0.00%
m : 0.00%
n : 0.00%
o : 0.00%
p : 0.00%
q : 0.00%
r : 0.00%
s : 0.00%
t : 0.00%
u : 0.00%
v : 0.00%
w : 0.00%
x : 0.00%
y : 0.00%
z : 0.00%
Aim to match the 2 decimal places shown above