- Go to https://docs.python.org/3/library/random.html and import the random library in Python
- Experiment with the following functions: random(), uniform(), randint(), gauss()
All the following questions will ask you to write a function. Always also think about some examples where you can guess what the outcome should be, and write the code to test the function.
1. Write a function that accepts an integer (n) and computes the value of n + nn + nnn. (nn means n times n.)
2a. Write a function that has as input parameter "guess" a guessed dice value, then throws a dice, and returns the difference between the thrown value and the guessed value.
2b. Change the above function to guess the sum of three throws instead.
2c. Write a function dice() that takes as input parameter the number of sides of the dice and returns a random dice throw. Edit the functions from 2a and 2b to use this function instead.
3. Write a function that accepts the radius of a circle as input and computes the area.
4. Take or rewrite the function that returns the Euclidean distance between two points.
5. Write a function that takes a first and last name as input and returns them in reverse order, with the last name in capitals.