Question: 1.Exercise1 You will write a function that will convert Fahrenheit temperatures to Celsius. Define a function named f_to_c with one parameter named f The function
1.Exercise1
You will write a function that will convert Fahrenheit temperatures to Celsius.
Define a function named f_to_c with one parameter named f
The function should take the value of f (which represents degrees Fahrenheit) and convert it to its equivalent temperature in Celsius using this formula:
Celsius = (Fahrenheit-32) / 1.8
The last instruction of the function should be to return the temperature in Celsius.
Special Note: Rounding
Although you have a little bit of experience with the Python round() function, do not use it here. Your function should return the complete result of the calculation.
main() Function
You must define a main() function where you will call the f_to_c(f) function and pass the argument.
Your main() function should also print the returned value (the converted temperature) to the terminal
Hints
- Print only the result of the calculation. Do not add additional language or annotation
- Do not try to do any rounding
- You do not need to include error handling
Test Your Code
Use the button below to test your code with a value of 32 degrees Fahrenheit. The output should be 0.0
TEST CODE - 32 DEGREES F
Use the button below to test your code with a value of 212 degrees Fahrenheit. The output should be 100.0
TEST CODE - 212 DEGREES F
2. Exer
cise 2
Module 04, Exercise 2
This exercise is worth 10 points
You will write a function that will calculate the price of a ride that uses a Pacers Bikeshare bike.
Define a function named ridecost with one parameter named minutes
The function will calculate the cost of the ride according to the following rules.
Calculating Ride Cost
Each ride costs $1.00, plus $0.15 for every minute OR PART OF A MINUTE.
Your function should accept an argument in the form of a float - e.g. 13.5. This represents thirteen and a half minutes.
The cost of a 13.5 minute ride would be 3.1. (See the next section for more information.)
Can you determine the formula you must use?
Special Note: Rounding
Although you have a little bit of experience with the Python round() function, it does not give us the precision to add trailing zeros.
For example, our calculation above results in 3.1 but we would like it to be 3.10, in order to represent three dollars and 10 cents.
We will demonstrate how to deal with currency values soon. For now, do not worry about rounding in your script.
main() Function
You must define a main() function where you will call the ridecost() function and pass the argument.
Your main() function should also print the returned value (the cost of the ride) to the terminal
Hints
- Print only the result of the calculation with NO leading "$". Do not add additional language or annotation.
- You need to import the math module. Why?! Review the Python Math Module Documentation
- You do not need to include error handling
3. Exercise3
main() Function
You must define a main() function where you will call the shipcost() function and pass the arguments.
Your main() function should also print the returned value (the cost of the shipment) to the terminal.
Hints
- Print only the result of the calculation with NO leading "$". Do not add additional language or annotation
- Do not try to do any rounding
- You do not need to include error handling
- the button below to test your code with a value of 10 oz. and 400 miles. The output should be 14.5
- Use the button below to test your code with a value of 28 oz. and 1285 miles. The output should be 41.425
- Use the button below to test your code with a value of 6 oz. and 2950 miles. The output should be 22.25
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
