Question: please write code in python For this project, you must write the code for the following function: def unit_converter (units, total_cost, from_currency, to_currency): The function

please write code in python

please write code in python For this project, you must write thecode for the following function: def unit_converter (units, total_cost, from_currency, to_currency): The

For this project, you must write the code for the following function: def unit_converter (units, total_cost, from_currency, to_currency): The function unit_converter converts the total_cost in from_currency to to_currency. units: number of gallons (for $) or liters (for C$) total_cost: USD dollars or CAD dollars paid for units from_currency: either '$' or 'C$' to_currency: either '$' or 'C$' Here's a typical use: # CAD/liter to USD/gallon USD_per_gallon unit_converter(61, 124.00, 'C$', 'S') # USD/gallon to CAD/liter CAD_per_liter unit_converter(16, 45.0, 'S', 'C$) You should use the same constant values for (unit conversions and exchange rates): LITERS_PER_GALLON = 3.78541 GALLONS_PER_LITER = 0.264172 # exchange rates CAD_TO_USD = 0.76 USD_TO_CAD = 1.31 You must handle all combinations of '$' and 'C$' for from_currency and to_currency. A '$' to '$' conversion would mean the answer is given in $/gallon. You can assume that if the from_currency is '$' then the units are gallons otherwise they are liters (we'll fix this later). The best strategy is to write the code that seems the clearest to you (perhaps using lots of if statements) and that it passes the tests. Write it so that you understand it. Don't continue until you pass the tests

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!