Write a function driving_cost () with input parameters miles_per_gallon, dollars_per_gallon, and miles_driven, that returns the cost...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a function driving_cost () with input parameters miles_per_gallon, dollars_per_gallon, and miles_driven, that returns the cost in dollars to drive those miles rounded to 2 decimal places. All items are of type float. Ex: If the input is: Enter miles per gallon: 20.0 Enter dollars per gallon: 3.1599 Enter miles to drive: 50.0 the return value of the function is: 7.89975 but the output is: 7.90 because we want dollars and cents as an answer. Ex: If the input is: Enter miles per gallon: 18.0 Enter dollars per gallon: 4.599 Enter miles to drive: 210 the return value of the function is: 53.65500 but the output is: 53.66 Output the floating-point value with two digits after the decimal point, which can be achieved using a format specifier in your print statement (%f) Your program must define and call a function: def driving cost (miles_per_gallon, dollars_per_gallon, miles_driven) Write a function driving_cost () with input parameters miles_per_gallon, dollars_per_gallon, and miles_driven, that returns the cost in dollars to drive those miles rounded to 2 decimal places. All items are of type float. Ex: If the input is: Enter miles per gallon: 20.0 Enter dollars per gallon: 3.1599 Enter miles to drive: 50.0 the return value of the function is: 7.89975 but the output is: 7.90 because we want dollars and cents as an answer. Ex: If the input is: Enter miles per gallon: 18.0 Enter dollars per gallon: 4.599 Enter miles to drive: 210 the return value of the function is: 53.65500 but the output is: 53.66 Output the floating-point value with two digits after the decimal point, which can be achieved using a format specifier in your print statement (%f) Your program must define and call a function: def driving cost (miles_per_gallon, dollars_per_gallon, miles_driven)
Expert Answer:
Answer rating: 100% (QA)
mainpy 2 1 def drivingcostmilespergallon dollarspergallon mi... View the full answer
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
What are some of the key challenges that companies might face when expanding into international markets?
-
2.17 LAB: Driving cost - methods Write a method drivingCost() with input parametersmilesPerGallon, dollarsPerGallon, and milesDriven that returns thedollar cost to drive those miles. All items are of...
-
Read the case study "Southwest Airlines," found in Part 2 of your textbook. Review the "Guide to Case Analysis" found on pp. CA1 - CA11 of your textbook. (This guide follows the last case in the...
-
27 01:08:40 In business decision-making, managers typically examine the two fundamental factors of: Multiple Choice Grow Hill Edurata Type here to search O Risk and capital investment. Risk and...
-
Show that, in general, a wrench can be replaced with two forces chosen in such a way that one force passes through a given point while the other force lies in a given plane.
-
Draw the pipleline timing diagram of: A) 2-stage pipeline with an example of a processor B) 3-stage pipeline with an example of a processor C) 5-stage pipeline with an example of a processor
-
For each of the following, (a) calculate the mean, standard deviation, and standard error of the mean for each Group and (b) construct a bar graph (assume the independent variable is condition and...
-
The Lyon Corporation is a merchandising company. Prepare a short-term cash forecast for July of Year 6 following the format of Exhibit 9A.4. Selected financial data from Lyon Corporation as of July 1...
-
Select information from BOINKE Corporation's financial statements is provided here. Balance Sheets as of December 31 Current Assets Net Plant and Equipment Total Assets Accounts Payable Notes Payable...
-
Allen Blay owns 100% of the stock in AB Corporation, organized ten years ago in California. AB operates a foreign branch in Country A. In the current yea r, AB reports $500,000 of taxable income from...
-
The Texas Brass Foundry has invested a great deal of time and money in occupational safety training for its employees and believes its occupational-related sick days are now below national average....
-
Several plants reach their plateau well before the end of the observation period. How is the analysis affected if repeated values are removed from the end of each series?
-
Explain the purpose and the implementation of the Box-Tidwell method. Why must the unmodified REML criterion be avoided?
-
How can we be assured that the log transformation is really needed or substantially beneficial? (Chap. 19).
-
The R commands are designed to decompose the total sum of squares additively into components associated with certain subspaces, which are mutually orthogonal for this design. Explain how to compute...
-
For \(y \in \mathbb{R}^{n}\), a decomposition of the total sum of squares \[ \|y\|^{2}=y^{\prime} y=y^{\prime} A_{1} y+\cdots+y^{\prime} A_{k} y \] is called orthogonal if each \(A_{r}\) is an...
-
Film reactions are short essays that will be assessed on how well students are able to apply one of the theories or viewpoints from a course text to the film itself. These assignments ask students to...
-
When is the indirect pattern appropriate, and what are the benefits of using it?
-
Jim (age 50) and Martha (age 49) are married with three dependent children. They file a joint return for 2012. Their income from salaries totals $50,000, and they received $10,000 in taxable...
-
The following additional information is available for the Dr. Ivan and Irene Incisor family from Chapters 1 and 2. On September 1, Irene opened a retail store that specializes in sports car...
-
Ken paid the following amounts for interest during 2012: Qualified interest on home mortgage...........................................$4,700 Auto loan...
-
Why are none of the bulbs in Figure 31. 24 lit? Data from Figure 31. 24 Figure 31.24 (1) (iii) NNN
-
In Figure 31. 26, bulb B is brighter than bulb C, which in turn is brighter than bulb A. Rank, largest first, \((a)\) the magnitudes of the potential differences across the bulbs, \((b)\) the...
-
In Figure 31. 25, identify the energy conversions that occur between points \(A\) and \(B, B\) and \(\mathrm{C}, \mathrm{C}\) and \(\mathrm{D}\), and \(\mathrm{D}\) and \(\mathrm{A}\). Data from...
Study smarter with the SolutionInn App