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
Which statement about synchronous communication is true?
tangare [24]
In general, synchronous communication means you have to wait for the answer all the time. The programming logic is simpler, but the cost that you spend a lot of time waiting.

If the options are:

<span>a. The people communicating don't need to be online at the same time.
b. There is lag time in the communication.
c. The communication occurs in real time.

a is false, you do need to be online to receive the message
b is true, typically you continue only after an acknowledgement
c is true, you wait for acknowledgement that occurs in real time (not necessarily fast though)</span>
3 0
3 years ago
Koi friend online hai kya​
Arlecino [84]

Answer:

yes

good afternoon friend

8 0
3 years ago
Denary is measured in Base 10 Binary is measured in Base________
anastassius [24]

Answer:

hey! the answer to your question is -

binary is measured in base 2

3 0
3 years ago
You have just used a command that produced some interesting output on the screen. You would like to save that information into a
Bogdan [553]

Answer: A. > interesting.txt

Explanation: From the command line, one can perform numerous tasks from navigating into a directory, creating a new directory, deleting files, create files, modify files and so on using simple commands. In the scenario above, after using a common which is used to produce an output on the screen, such as the 'echo' command, one may wish to save the file giving the user the ability to access the file later. Since it is stated the file name 'interesting.txt' given to the file does not currently exist, appending the sign > saves the file. If the filename already exists, it will overwrite the existing content.

6 0
3 years ago
Based on the relational model, create the database metadata as part the physical designphase.b)from the metadata, write the sql
galben [10]
<span>Which is not a component of a database that describes how data is stored?</span>
5 0
3 years ago
Other questions:
  • Does the steelseries arctis 9x work with a pcie bluetooth card in windows
    13·1 answer
  • Which of the following domain types is most trustworthy 1) .com 2) .tv 3).org 4) .edu
    15·2 answers
  • 18. Which type of briefing is delivered to individual resources or crews who are assigned to operational tasks and/or work at or
    14·1 answer
  • Write a pseudocode thats accept and then find out whether the number is divisible by 5 ​
    6·1 answer
  • You are having problems on your Windows 7 computer and you pull up Device Manager to see if there are any alerts. Two of your de
    11·1 answer
  • How does form get its power natural gas
    14·1 answer
  • The process of combining rows and columns in a table is called _____.
    8·1 answer
  • Write an If/else statement to check whether host is online. If it is online, then print system is online otherwise print system
    13·1 answer
  • In a three-tier architecture, the component that runs the program code and enforces the business processes is the:_______.
    11·1 answer
  • What is the importance of using Onedrive in Windows 10 and how knowledge of it will have an impact in today's workplace?
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!