Exercise 5: answer
Exercise 6: square
Exercise 7: average