# Python Score Function

11 Pages2022 Words1178 Views
|
|
|
UMUC Data 620 Assignment 8.2Your name:Date: Turn in separate files with the following items. Please label each with the TURN IN # statement so we can easily follow it.DeliverableDescriptionPointsTURN IN #1Severance Chapter 3 - Exercise 3 – score the grades, with screen shots of execution. Code will be graded according to Python rubric.5TURN IN #2 Severance Chapter 4 - Exercise 7 – score the grades using a function, with screen shots of execution. Code will be graded according to Python rubric.5TOTAL10
Study Chapters 3 and 4 of “Python for Everybody – Exploring Data using Python 3” by Charles Severance.The following walkthrough exercises from the book are included here: Chapter 3: Exercises 1, 2Chapter 4: Exercises 5, 6Severance Chapter 3 - Exercise 1Rewrite your pay computation to give the employee 1.5 times the hourly rate for hours worked above 40 hoursEnter Hours: 45Enter Rate: 10Pay: 475.0This program builds upon our Week 7 program for computing pay. In this example, we need to compute pay slightly differently, depending on whether the user entered number of hours greater, equal or less than 40. For number of hours worked equal to 40 or below, the standard computation of number of hours * rate applies. For more than 40 hours worked, those extra hours are paid at 1.5 times the computation above. Here we will assume that the user supplied a valid numeric value for the number of hours and rate. The screenshot below demonstrates.
Figure 1 – Chapter 3 - Exercise 1 (1)The first thing to note is that we have assigned the number 40 to a variable or placeholder, and used thisvariable everywhere in the program where we need to refer to the 40 hours. This is good programming practice, because if this number were to change in the future (due to a policy change, for instance), we can modify the value in one place, instead of finding and updating the constant number 40 that might appears in various places in our program. Note, we could have also stored 1.5 similarly into a variable placeholder.Secondly, note the use of the conditional “if” statement. If the number of hours worked was over 40, wetake the difference of these hours from 40. Then, we apply the standard pay computation for the 40 hours, and the 1.5 multiplier to the extra hours worked. Check out the program output below:
Figure 2 – Chapter 3 - Exercise 1 (2)Severance Chapter 3 - Exercise 2Rewrite your pay program using try and except so that your program handles non-numeric input gracefully by printing a message and exiting the program. The following shows two executions of the program:Enter Hours: 20Enter Rate: nineError, please enter numeric input***Enter Hours: fortyError, please enter numeric inputTake a look at this program below:

## End of preview

Want to access all the pages? Upload your documents or become a member.

Related Documents
|2
|386
|387

|1
|438
|428

|7
|942
|37

### Support

#### +1 306 205-2269

Chat with our experts. we are online and ready to help.