Solution for Problem 4

Using Python