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
crimeas [40]
2 years ago
5

Implement a class Car with the following properties. A car has a certain fuel efficiency (measured in miles/gallon or liters/kmâ

pick one) and a certain amount of fuel in the gas tank. The efficiency is specified in the constructor, and the initial fuel level is 0. Supply a function drive that simulates driving the car for a certain distance, reducing the fuel level in the gas tank, and functions get_gas, to return the current fuel level, and add_gas, to tank up. Sample usage:Car my_beemer(29); // 29 miles per gallonmy_beemer.add_gas(20); // Tank 20 gallonsmy_beemer.drive(100); // Drive 100 milescout << my_beemer.get_gas() << "\n"; // Print fuel remaining
Computers and Technology
1 answer:
zvonat [6]2 years ago
3 0

Answer:

class Car(object):

   fuel = 0

   def __init__(self, mpg):

       self.mpg = mpg

   def drive(self, mile):

       if self.fuel * self.mpg >= mile:

           self.fuel -= mile / self.mpg

       else:

           print(f"get gas for your {self}")

       print(f"Fuel remaining: {self.fuel}")

   #classmethod

   def get_gas(cls):

       cls.fuel += 50

   #classmethod

   def add_gas(cls, gallon):

       if cls.fuel + gallon > 50:

           cls.fuel += 10

       else:

           cls.fuel += gallon

gulf = Car(20)

gulf.get_gas()

gulf.drive(200)

Explanation:

The Car class is defined in Python. Its drive method simulates the driving of a car with fuel that reduces by the miles covered, with efficiency in miles per gallon. The get_gas and add_gas methods fill and top up the car tank respectively.

You might be interested in
The replacer parameter of the stringify method accepts a/an ______________ or an array.
Elina [12.6K]

Answer:

The answer is function

Explanation:

As a function, it accepts two parameters: the value and the key being stringified.  It can be used to change the value of the entries or eliminate them. As an array, it specifies by name which entries and names of the properties in the object to include in the resulting JSON string.

7 0
3 years ago
The process of changing data from their original form to a format that more closely fits the research objectives of the research
lys-0071 [83]

ANSWER- True


Data transformation is defined as the process of converting data or information from one format to another. Usually, the data or information is changed from the original format (The format of a source system) into the required format of a new destination system; a format that fits the objectives of the research/study.

8 0
3 years ago
What is the correct keyboard shortcut to cut a cell value
vladimir2022 [97]

Answer:

Cntrl+X

Explanation:

Do it on your computer

4 0
2 years ago
MoonieStardust Here is the rest of the picture from my last question you answered.
Oliga [24]

Answer:

the two on the bottom and the two on the top

Explanation:

move the two on the bottom apart and the two on the top inward

6 0
2 years ago
Read 2 more answers
ANSWER QUICKLIY
lidiya [134]

Answer:

Explanation:

Allow you to view the document in different ways. Sorry if I am wrong. I am dumb

God bless, stay safe, and good luck! :)

4 0
3 years ago
Read 2 more answers
Other questions:
  • What filter gives a “squeezed” effect to an image?
    14·2 answers
  • Which button would you use to quickly add addresses to a mail merge envelope?
    5·1 answer
  • Obtain a file name from the user, which will contain data pertaining to a 2D array Create a file for each of the following: aver
    5·1 answer
  • When you use a script to create all of the tables for a database, you must start with the tables that don't have _______________
    15·1 answer
  • Please answer this a due tomorrow!!!
    5·1 answer
  • 3.26 LAB: Leap Year A year in the modern Gregorian Calendar consists of 365 days. In reality, the earth takes longer to rotate a
    15·2 answers
  • They are correct? thank you!
    6·2 answers
  • Dora has inserted a text box into a Word document that she is formatting. Which strategy will not format text boxes? Create a li
    6·2 answers
  • Can you predict what changes will come to data storage in the next decade? 
    12·1 answer
  • What is Utility Software ? Name any two utility programs. <br>​
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!