Graded Problem Set #2.4
Functions (New Code)
Background
These problems should be completed on your own. Unlike the practice problems, where you are allowed, and even encouraged, to talk about the process with your classmates, these should be attempted on your own. If you have difficulty with these, please reach out to me for assistance or guidance.
These problems will be completed using an editor such as Thonny or IDLE and submitted to Autolab for grading.
Activities
Please try to make your program output look as much like the example as possible and verify it works with the example input provided. If you have difficulty finding the information or understanding how to approach the problem, you should contact me.
To complete this activity, you will need to create the following functions:
- Func G5 - cellBill()
- Func G6 - getCategory()
- Func G7 - getMedian()
- Func G8 - getsLoan()
Func G5
Who doesn't buy the unlimited plan?
Fiona Friend is a senior citizen looking at getting a new cell phone carrier. She doesn't use her phone that much so she is looking at a cut rate plan from Geezer Mobile.
The traditional plan from Geezer Mobile includes 90 minutes of air time and 60 text messages each month for only $8.00.
But, if you go over those amount they charge $0.20 for each additional minute and/or $0.10 for each additional text. All cell phone bills include a charge of $0.72 to support 911 call centers. The entire bill (including the 911 fee) is subject to a 7% sales tax
Write a Python function that conforms to the following
- Function name
- cellBill()
- Parameter(s)
- minutes of air time
- number of texts
- Return value
- the total monthly bill
- round the bill to two decimal places (yes, I know this is a change from many previous programs)
- Example(s)
Func G6
The Dreaded BMI
BMI is one of those things that the medical profession debates whether it is valid and/or helpful. But it seems to kick around still.
This function starts with the code you wrote earlier in the course about BMI
[NOTE: Please use this formula exactly as written. That is, multiply by 703 before you divide.]
but rather than returning the mathematical score, it returns your "category" as taken from the CDC website
Write a Python function that conforms to the following
- Function name
- getCategory()
- Parameter(s)
- weight in lbs
- height in feet
- remaining height in inches
- Return value
- a String representing your BMI category using the formula and categories from above
- Example(s)
- Special Note:
- Remember from our discussion in the FCCS class that the computer can be imprecise when dealing with decimals. This problem has one VERY small gotcha caused by this.
- You will get one answer if you do (weight * 703) / height**2
- and a close but different answer if you do weight / height**2 * 703
- It's VERY small. But it will cause problems in one of my test cases.
- PLEASE use the formula I give above (which is the first version) and not the second version.
- Remember from our discussion in the FCCS class that the computer can be imprecise when dealing with decimals. This problem has one VERY small gotcha caused by this.
Func G7
Here I am, stuck in the middle with you
Malcolm has always liked things in the middle. Can you help him find them?
Write a Python function that conforms to the following
- Function name
- getMedian()
- Parameter(s)
- three integers
- Return value
- the value of the one that is in the middle
- Example(s)
- Special Instructions
- This is intended as a conditional problem. There are way to do it using math and no conditionals. You should NOT use those.
- For sake of argument, we are going to assume that the three parameters are each unique values - no repetition.
Func G8
Do I get the loan?
Rob Umblynd is a banker who works in the mortgage department of his bank. He uses the following information to decide if you get a mortgage or not:
- The HTI ratio is no more than 0.28 [28%. But for a variety of mathematical reasons we need to use it in the decimal format]
- HTI is "housing to income" and is the ratio of the expected monthly house payment to the current monthly income
- The DTI ratio is no more than 0.36 [Ditto. This is 36% but we need to use it as a decimal]
- DTI is "debt to income" and is the ratio of all of the expected debts (current monthly debt payments plus expected monthly house payment) to the current monthly income
[Note, this formula and statistics came from https://www.investopedia.com/terms/q/qualifying_ratios.asp]
Write a Python function that conforms to the following
- Function name
- getsLoan()
- Parameter(s)
- current monthly income
- current monthly debt payments
- expected monthly house payment
- Return value
- True if the customer qualifies for the loan
- False if the customer does not qualify for the loan
- Example(s)