Erica's Chapter 5 Exercises

by Erica Brody

03 Feb 2016

Exercise 1: Write a program which repeatedly reads numbers until the user enters “done”. Once “done” is entered, print out the total, count, and average of the numbers. If the user enters anything other than a number, detect their mistake using try and except and print an error message and skip to the next number.

Exercise 2: Write another program that prompts for a series of numbers as above and at the end prints out the maximum, minimum and average of the numbers.

Reflection: I know that these exercises aren’t supposed to take long - as a beginning programmer, I spent about 90 minutes total figuring these out. It was helpful to use scrap paper to write out the different mini steps that had to be accomplished to reach the goal. And the best part, I found one of my errors funny today. While working on generating the minimum number in the list input by the users, the output kept saying “Done” or “d” - I realized that I was calculating the minimum after I checked for the word Done in the output - so the computer was getting the minium of “done”. In this case, output was very helpful in figuring out where the error was.

I am a library science student, focused on health information. I am dabbling in information science this semester. Find Erica Brody on Twitter, Github, and on the web.