Limited-time offer! Save up to 50% Off | Solutions starting at $6 each  

Exploring Data using Python: Assignment

Added on - 16 Sep 2019

Trusted by 2+ million users,
1000+ happy students everyday
Showing pages 1 to 4 of 11 pages
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 wecan easily follow it.DeliverableDescriptionPointsTURN IN #1Severance Chapter 3 - Exercise 3 – score the grades, with screenshots of execution. Code will be graded according to Pythonrubric.5TURN IN #2Severance Chapter 4 - Exercise 7 – score the grades using afunction, with screen shots of execution. Code will be gradedaccording 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 40hoursEnter Hours: 45Enter Rate: 10Pay: 475.0This program builds upon our Week 7 program for computing pay. In this example, we need to computepay slightly differently, depending on whether the user entered number of hours greater, equal or lessthan 40. For number of hours worked equal to 40 or below, the standard computation of number ofhours * rate applies. For more than 40 hours worked, those extra hours are paid at 1.5 times thecomputation above. Here we will assume that the user supplied a valid numeric value for the number ofhours and rate. The screenshot below demonstrates.
Figure1– 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 programmingpractice, because if this number were to change in the future (due to a policy change, for instance), wecan modify the value in one place, instead of finding and updating the constant number 40 that mightappears in various places in our program. Note, we could have also stored 1.5 similarly into a variableplaceholder.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 40hours, and the 1.5 multiplier to the extra hours worked. Check out the program output below:
Figure2– Chapter 3 - Exercise 1 (2)Severance Chapter 3 - Exercise 2Rewrite your pay program using try and except so that your program handles non-numeric inputgracefully by printing a message and exiting the program. The following shows two executions of theprogram:Enter Hours: 20Enter Rate: nineError, please enter numeric input***Enter Hours: fortyError, please enter numeric inputTake a look at this program below:
You’re reading a preview
Preview Documents

To View Complete Document

Click the button to download
Subscribe to our plans

Download This Document