Jay's Chapter 5 Loops Exercises

by JayYang95

03 Feb 2016

Exercise 1:

This exercise was rather simple. I kept track of the count in a variable that incremented by 1 everytime the user entered an integer and added that integer to the overall sum. The average was calculated at the end by dividing the total sum by total count.

Exercise 2:

For this exercise, I created a min and max variable at the beginning initially set to None. In the loop, if min or max were equal to None, then whatever integer the user entered would become it. The purpose of this was to set the first value the user entered to both the max and min. Once the loop continued to cycle, it would check if newly inputted values were lesser than or greater than the current min/max, replacing the respective values if they were.

Here's a little about JayYang95 Find JayYang95 on Twitter, Github, and on the web.