1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
butalik [34]
3 years ago
8

Write a program with a car's miles/gallon and gas dollars/gallon (both floats) as input, and output the gas cost for 10 miles, 5

0 miles, and 400 miles. Ex: If the input is 20.0 3.1599, the output is: 1.57995 7.89975 63.198 Note: Small expression differences can yield small floating-point output differences due to computer rounding. Ex: (a + b)/3.0 is the same as a/3.0 + b/3.0 but output may differ slightly. Because our system tests programs by comparing output, please obey the following when writing your expression for this problem. First use the dollars/gallon and miles/gallon values to calculate the dollars/mile. Then use the dollars/mile value to determine the cost per 10, 50, and 400 miles. Note: Real per-mile cost would also include maintenance and depreciation.
Computers and Technology
1 answer:
omeli [17]3 years ago
5 0

Answer:

The Following are the code to this question:

def cost(miles, milesPerGallon, dollarsPerGallon):##defining a method cost that accepts three parameter

   return miles / milesPerGallon * dollarsPerGallon# calculate cost and return it value  

milesPerGallon = float(input('Enter miles/Gallon value: '))#defining variable milesPerGallon for user input  

dollarsPerGallon = float(input('Enter dollars/ Gallon value: '))#defining variable dollarsPerGallon for user input

print('{:.5f}'.format(cost(10, milesPerGallon, dollarsPerGallon)))#call method and print its value

print('{:.5f}'.format(cost(50, milesPerGallon, dollarsPerGallon)))#call method and print its value

print('{:.3f}'.format(cost(400, milesPerGallon, dollarsPerGallon)))#call method and print its value

Output:

Enter miles/Gallon value: 20.0

Enter dollars/ Gallon value: 3.1599

1.57995

7.89975

63.198

Explanation:

In the above-given code, a method "cost" is defined, that accepts three value "miles, milesPerGallon, and dollarsPerGallon" in its parameter, and use the return keyword for calculating and return its value.

In the next step, two variable "milesPerGallon, and dollarsPerGallon" is declared, that use the input method with float keyword for input floating-point value.

After input value, it uses a print method with different miles values, which are "10,50, and 400", and input value to pass in cost method to call and print its return value.

You might be interested in
Dr. Thomas likes to follow up with her patients to make sure they were happy with their care. She sends all patients an email en
timofeeve [1]

Answer:

lean media

Explanation:

Dr. Thomas uses email as a medium of lean media to convey messages.

Lean media may be defined as the source of conveying messages that are short or of lean capacity. It is meant for instant messages and message and information that is not considered to be of out most importance. Whereas a rich media is a video chat or face to face communication.

Dr. Thomas send emails to her patients to follow up with them and also encourages her patients to call her for appointments or any questions. She uses email as a source of lean media for this communication.

8 0
3 years ago
Read 2 more answers
What is the on board storage C:
sasho [114]
On-board? im assuming so. an on-board storage is where people keep luggage/items on a ship.

hopefully i could help ;)
7 0
3 years ago
Question 1
blondinia [14]

Answer:

888 + 88 + 8 + 8 + 8 = 1000

Explanation:

Required

Add up to 1000 using only digit 8

There is no straight way to answer this question; so, we make use of trial by error method to arrive at our solution.

After several trials, I found out that:

888 + 88 + 8 + 8 + 8 = 1000

6 0
3 years ago
¿Cuál es la influencia de las redes sociales en casa?
Natalka [10]
La influencia de las redes sociales en la casa puede variar. Primero puede ser bueno porque podemos usar las redes sociales para ver recetas de cocina para hacer en casa. Segundo puede ser malo porque las personas de la casa podrían sufrir acoso cibernético .
3 0
3 years ago
Which approach does procedural programming follow? bottom up, top down, random, or object oriented​
ELEN [110]

Answer:

Top to down approach

Explanation:

7 0
3 years ago
Other questions:
  • Which routine best ensures email safety?
    7·2 answers
  • To use the program service routines, the user's program makes requests to the operating system through the
    10·1 answer
  • More recent GPU families such as Fermi and Kepler have adopted CPU-style virtual memory architecture with a____________-bit virt
    8·1 answer
  • Customizing ads to people who had earlier visited the site is
    14·1 answer
  • The average price of milk increased from $3.00 last year to $3.50 this year. This is most likely due to:
    14·1 answer
  • Write a program that keeps track of a simple inventory for a store. While there are still items left in the inventory, ask the u
    12·2 answers
  • Explain the following terms <br><br>copyleft:<br><br>creative Commons:<br><br>GNU/GPL:​
    8·1 answer
  • The objective of this task is to use Scapy to estimate the distance, in terms of number of routers, between your VM and a select
    7·2 answers
  • Difference between switch and switch lite
    10·1 answer
  • What actions might contribute to recommendations you see online?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!