Q4 and Q5 from Udacity programming languages exam