Vroom! Vroom!

Ukończone Opublikowano 5 lat temu Płatność przy odbiorze
Ukończone

Create a python3 file (or module) called [login to view URL] that contains the following functions. When you run this file, make sure that the main function is invoked.

main:

• Prompts the user for the tank size (in gallons).

• Prompts the user for the miles per gallon.

• Prompts the user for the cost per gallon.

• Invokes the travel function from [login to view URL] with the tank size, miles per gallon, and cost per

gallon as arguments in that order. The string returned from the travel function is displayed on the console. The travel function is described below.

The [login to view URL] File

You will declare two global variables for total distance traveled and net miles traveled. You need to name these two variables total_distance and net_miles, respectively. The list of the parameters and return values for the functions below assume these global variables exist.

[login to view URL] travel function

The travel function is the primary function for the car simulation. All the other functions are called either directly or indirectly from the travel function. The travel function has three parameters: the tank size, the miles per gallon, and the cost per gallon in that order. It should do the following in orderfind_max_distance: Accepts the tank size and miles per gallon as parameters in that order.

Returns the total possible number of miles that could be traveled rounded to two decimal places.

2. user_loop: Accepts the max distance as its parameter. It does not return anything. See its

description in the next section.

3. find_gallons: Accepts the miles per gallon as parameters. This function tries to compute the

number of gallons used given the total distance the car has traveled and the miles per gallon. This computation is done inside a try-except block. If the calculation causes a division by zero error, then an exception will be thrown by the python interpreter. If an exception is thrown, then “MPG is Zero!” is displayed on the console and zero is returned. If an exception is not thrown, then the number of gallons needed (that is, the result of the division) is returned rounded to two decimal places.

4. find_total_cost: Accepts two parameters, the number of gallons and the cost per gallon in that order. Returns the total cost rounded to two decimal places.

5. report_stats: Accepts two parameters which are total cost and number of gallons used in that order. Construct and returns a string. that has the following features. The report_stats function has no print statements in it when you submit it (you might want to have some print statements in it temporarily while debugging)! The format of the string must be identical to the examples in the example runs later in this handout. The features of the returned string are as follows.

• The total miles traveled.

• The net miles traveled.

• The number of gallons used.

• The total cost.

• A message describing the total cost as shown below:

◦ ``Cha Chiiinng!'' if the total cost is less than 25.00 dollars.

◦ ``Wallet getting nervous!'' if the total cost is equal to or greater than 25.00 dollars but

less than 100.00 dollars

◦ ``Ouch!'' if the total cost is 100.00 dollars or more.

Python

Numer ID Projektu: #18018598

O projekcie

8 ofert Zdalny projekt Aktywny 5 lat temu

Przyznany użytkownikowi:

DevStar925

How are you? Like you see in my profile and portfolios, I have rich experience in C/C++, C#, and Python programming. I would like to discuss with you and get more detail requirements. Please give me your details, th Więcej

$25 USD / godzina
(9 ocen)
5.6

8 freelancerów złożyło ofertę na średnią kwotę $20/godzinę w tym projekcie

andrewemel

Hi there, I would like to be considered for your project. I have 3+ years of experience in Python. I'll be glad to help. Best regards, Andrew

$17 USD / godzina
(36 Oceny)
4.9
ExperSolutions

Hi we are expert in python we are working for machine learning and data science supervised and unsupervised algorithms e.g Decision trees, SVM, Random forest, KNN, Regression, Clustering, ANN, RNN and specifically in Więcej

$20 USD / godzina
(2 Oceny)
2.0
bernardopoliv

Hello! I am very interested in this project. As an economist and VBA & Python developer, I think Ive got the skill set required do complete this task. Hopefully, you will give me a chance to show my work. Thank you Więcej

$20 USD / godzina
(1 Ocena)
0.8
Silfalion

I’m a computer science student and have experience in programming in Java and also some in Python enough for the project to be done easily.

$16 USD / godzina
(0 Oceny)
0.0
mpedrosab

I am a Physics graduate with great experience in programming in Python acquired during the career and some research projects. I will do your task in a short time.

$15 USD / godzina
(0 Oceny)
0.0
syedaqeelawais1

My education, experience, and my skills in the area of computer science make me a great candidate for this position.

$22 USD / godzina
(0 Oceny)
0.0