Payal's Chapter 3 Variable Posts

by Payal Patel

21 Jan 2016

Chapter 3, Exercise 1: Rewrite your pay computation to give the employee 1.5 times the hourly rate for hours worked above 40 hours.

Chapter 3, Exercise 2: Rewrite your pay program using try and except so that your program handles non-numeric input gracefully by printing a message and exiting the program.

Chapter 3, Exercise 3: Write a program to prompt for a score between 0.0 and 1.0. If the score is out of range, print an error message. If the score is between 0.0 and 1.0, print a grade using the following table:

Reflection: While going through the readings initially, try and except were a bit confusing to me. However, when I started the exercises for chapter three, I found that they are not as complicated as I had initially thought. Also, I started to see a similarity between the purpose of try/except and conditional statements (the try part of the statement seems similar to the the if statement and except seems similar to the else statement). Comparing it in this way helped me better understand and utiilze try and except in my program.

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