Paired Programming Activity
Functions (New Code)
Activities
I would like you to complete four Python functions working with your partner.
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. You may make them all in the same file on Replit.
- Func 5 - windchill()
- Func 6 - fahrToCel()
- Func 7 - carFee()
- Func 8 - taxesOwed()
Func 5
Calculating Windchill
Cole Dwind is the meteorologist for the local weather station. He is getting ready for the approaching winter by brushing up on the calculation for wind chill. According to Wikipedia the formula for wind chill is:
Write a Python function that conforms to the following
- Function name:
- windchill()
- Parameter(s)
- air temperature in degrees Fahrenheit
- wind speed in MPH
- Return value
- the wind chill as calculated
- you should not round the answer in any way
- Example(s)
- Special Instructions
- There is a non-integer exponent in this formula. Read through the documentation for the math module to determine how you do this in Python.
- https://docs.python.org/3/library/math.html
Func 6
Converting the temps
Gail Storm is a meteorologist in Detroit. Since about half of her audience is just across the border in Canada, she has to report the temps in both Fahrenheit and Celsius.
Write a Python function that conforms to the following
- Function Name
- fahrToCel()
- Parameter(s)
- the temperature in Fahrenheit
- Return value
- the temperature in Celsius
- as calculated. You should not round/format the answer in any way
- Example(s)
Func 7
TC Works the Motor Pool
Budgets are tight at UNI. Everyone is doing extra duties. As part of this TC (The Cat. Our school mascot.) has started to help over at the motor pool where the University rents cars to faculty members for business trips. If a department wants to rent a car from the motor pool it costs:
- $40.00 per day
- AND
- $0.28 per mile driven
Write a Python function that conform to the following:
- Function name
- carFee()
- Parameters
- Number of days the car was rented
- Starting mileage on the odometer
- Ending mileage on the odometer
- Return value
- The cost of the rental using the info provided above
- Examples
- Special Notes
- Do NOT round or format the results
Func 8
TC Works in the office of Human Resources
TC has jumped over to HR to help in the accounting department. This month his job is to help generate the W2 forms that tell employees what taxes they owe for the year.
Suppose that the federal government has implemented a new "easy" tax rate
- You pay 0% on the first $10,000.
- You pay 10% on the next $10,000 (the amount from $10,000-$20,000)
- You pay 20% on the next $50,000 (the amount from $20,000-$70,000)
- You pay 30% on anything over this (any amount greater than $70,000)
Write a Python function that conforms to the following:
- Function name
- taxesOwed()
- Parameters
- The employee's annual salary
- Return value
- The total taxes due
- Examples
- Special Notes
- Do NOT round or format the result
- Note that this is an incremental tax. That means that if you make $100,000 you don't owe 30% of 100,000. Instead:
- First $10,000 yields $0 tax
- Next $10,000 yields $10,000*10% or $1000 tax
- Next $50,000 yields $50,000*20% or $10,000 tax
- Final $30,000 yields $30,000*30% or $9,000 tax
- For a grant total of $20,000 in taxes