NOTE: for all these exercises, only use while-loops (or recursion), not for-loops. Where you can use functions you wrote in earlier exercises, you should always do so.
1a. Write a function with parameter N, that throws N dice and returns the sum.
1b. Write a function with parameters N and K, that, using the previous function, throws N dice and returns True when the sum is equal to K.
1b. Write a function with parameters N, R, and K, using the previous function, that throws N dice R times and returns what proportion of results the sum of the N dice is exactly K.
2a. Write a simulation that calculates the number of infections after 100 time periods, when you start with 1 infected person, with each time step, for each infected person, a 15% chance of being cured, and a 25% chance of infecting one new person.
2b. Write a function that takes parameters N_start, N_times, P_infection and P_cure, representing the number of infected persons at the start, the number of time steps, the chance of infecting another person in each time step, and the chance of being cured in each time step, and that returns the number of infected persons at the end of the simulation.
2c. Run the above simulation 20 times, with each time N_start=2, N_times=100, P_infection=0.25, P_cure=0.10. Experiment with different values to see results.
BONUS EXERCISES
3a. Write a function that randomly, with equal probability for each outcome, returns either "up", "down", "left", or "right".
3b. Write a function that takes a parameter N and then starting with (x,y) coordinates at (0,0), takes N steps in random directions, and returns the Euclidean distance between the start and end points.
4a. Write a function that takes the borrowed amount, the interest rate, and the number of months as input parameters, that prints for each month the total borrowed amount and returns the end loan.
4b. Change the above function by adding a parameter for the monthly downpayment and take this into account. For each month, the downpayment is subtracted after interest has been added (i.e. at the end of the month).