Payal's Chapter 5 Loops Exercises

by Payal Patel

03 Feb 2016

Chapter 5, Exercise 1:

Chapter 5, Exercise 2:

Reflection:

At first I thought both of these exercises were difficult. I was having trouble starting, so in order to deal with this I split up the problems into divisible and more manageable tasks. I then arranged them in an order that I thought made logical sense (in terms of completing each of these smaller subtasks). For me this helped a lot—I was able to focus on smaller tasks and then piece them together once I had finished the components.

In the Chapter 5 reading, counting/summing/maximum/minimum loops were created using for loops. I thought about using this, however, it seemed simpler to use the while loop and try/except. To determine the maximum and minimums, I created an empty list which would then store numbers entered in by the user. After that I calculated the maximum and minimum of this list and stored them into maximum and minimum variables, respectively.

Overall, I found this exercise challenged me to think of how I could solve these problems. These exercises helped me further understand the coding process and different approaches one can take when writing a program.

Payal is a junior at UNC-Chapel Hill majoring in Information Science. Find Payal Patel on Twitter, Github, and on the web.