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
A teacher determines student percentages in a course as the points a student earns divided by the total points available in the
Ainat [17]
I think it will be E
8 0
3 years ago
In Activity 6.4 we asked you to compare the experience of playing the game of Snake on a
alexandr402 [8]

Answer:

start with what you know

Explanation:

8 0
3 years ago
An OS X backup utility that automatically backs up files to a dedicated drive that is always available when the computer is turn
Darya [45]

Answer:

Time machine.

Explanation:

An OS X backup utility that automatically backs up files to a dedicated drive that is always available when the computer is turned on is called a time machine.

OS X was released in 2001 and it's Apple's version ten (10) of the operating system that runs on its Macintosh computers.

A time machine is a software tool built into the Mac operating system and it is primarily designed to automatically backup user files or data onto a dedicated drive such as an external hard drive disk through a wired connection, by using a Thunderbolt or universal serial bus (USB) cable. The automatic backup can as well be done wirelessly through a network connection.

5 0
3 years ago
Janet needs to flag a message for follow-up in Outlook. Which option is not a default?
kari74 [83]
Answer:

Explanation:

Today
5 0
3 years ago
Read 2 more answers
What is a file manger ? The file manger is user A . Medium B.platform C. Interface .
zysi [14]

Answer: C. Interface.

Explanation:

File manager is an interface between the hardware part of a computer and the software. the main function of a file manager is to help the user manage all files which they have stored up on their computers. for example the file managers allows the users to view, copy, delete and edit the files which they have stored up on their computer storage devices.

5 0
4 years ago
Other questions:
  • âwhat two log files are used by older versions of unix and newer version of linux to store log information
    10·2 answers
  • When do on loop conditions happen? (1 point)
    5·1 answer
  • What security principle does a firewall implement with traffic when it does not have a rule that explicitly defines an action fo
    13·1 answer
  • What is a piece of information sent to a function
    15·1 answer
  • A ? is the desired value where a process should be maintained. The value may be manually set, automatically set, or programmed.
    13·1 answer
  • The purchase of a computer by a person for household use would be counted in what category of GDP?
    15·1 answer
  • 20 POINTSS!! NEED HELP!!
    12·2 answers
  • Write a recursive function is_pow2(n) that returns True if the positive integer n is an integer power of 2, and False otherwise.
    9·1 answer
  • A router periodically goes offline. Once it goes offline, you find that a simple reboot puts the router back online. After doing
    12·1 answer
  • Diferencias entre ciencia y tecnologia
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!