Activity : Assignment Set #4
The following assignments are written in a very different format from the previous four weeks of python assignments. In each of these assignments you are to write a single function which MUST follow the naming and parameter requirements of the problem exactly. Your file should contain ONLY that function. It should not include any additional code.
When testing your code you should use the shell prompt examples provided. Your code must behave exactly the same way or it will not pass the Autolab tests.
THIS MEANS:
- No input statements in your functions
- No print statements in your functions
- Functions must RETURN the data requested in the problem specification
To complete this activity, you will need to create the following programs:
- FUNC_05 uber.py
- FUNC_06 retire.py
- FUNC_07 bmiCategory.py
- FUNC_08 paycheck.py
FUNC_05
In a file called uber.py create a function called calculateFare()
- In a file called uber.py
- Write a function called calculateFare()
- This function takes in one (1) parameter:
- The distance in miles
- This function will calculate and return
- A floating point number rounded to no more than two decimals
- This cost of the uber fare.
- The calculation for this is based on:
- Inital Charge = $2.15
- Charge for every 500 feet = $0.17
- Charged as soon as you START the next 500 feet
- Remember that there are 5280 feet per mile.
- This means that a trip of even 1 foot would cost $2.32
- Here are some examples
FUNC_06
In a file called retire.py create a function called canRetire()
- This function works very similarly to the code you wrote in 8.f
- In a file called retire.py
- Write a function called canRetire()
- This function takes in two (2) parameters:
- Your age
- Your years of service
- This function returns
- A boolean value (True/False)
- This indicates whether you can retire based on the IPERS rules
- sum of age and years of service equals or exceeds 88
- age is at least 62 and years of service is at least 20
- age is 65 or more.
- Here are some examples:
FUNC_07
In a file called bmi.py create a function called getCategory()
- This function starts with the code you wrote in 10.b
- In a file called bmi.py
- Write a function called getCategory()
- This function takes in three (2) parameters:
- Your weight in pounds
- Your height in feet
- Your height in remaining inches
- Recall that the formula for bmi is:
- This function will calculate and return
- A String
- This string represents your category on the BMI classification chart (the following is taken from the CDC website
- Here are some examples:
FUNC_08
In a file called paycheck.py create a function called calculatePay()
- This function works very similarly to the code you wrote in 8.a
- In a file called paycheck.py
- Write a function called calculatePay()
- This function takes in two (2) parameters:
- How much you make per hour
- The number of hours you worked during the week
- This function will calculate and return
- A floating point number formatted to no more than two decimal places
- This number represents your total pay based on:
- Regular pay for the first 40 hours
- "Time and a half" for everything over 40 hours
- Here are some examples:
Testing Your Code
- Go to the AutoLab Homepage for the course
- https://hypnos.cs.uni.edu/courses/CSED1320-F21/assessments
- Log in if necessary
- For each of the assignments listed above, find their submission link under the "Practice" heading
- Upload the corresponding python file for that assignment.
- When the "handin history" page comes up you will need to refresh the page until a score of either 0 or 1 is shown with your assignment.
- Click on the 0/1 score to get feedback.
- Read the information carefully if you received a score of 0 and figure out what you need to do to fix the problem.
- Ask for help from me or other students if you don't understand an error message.
- Resubmit until the program earns a 1.