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]
3 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]3 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
What should you do when an error message pops up on the screen?
gladu [14]
D.) Write down the error message and research the cause based on the message.
5 0
3 years ago
Read 2 more answers
When should an individual consider entering parenthood?
-BARSIC- [3]
  In my opinion, after marriage. And during the time you're married, be sure you are going to stay with that person a long time because divorces can cause mental health issues towards the child. And if your loved one is abusive, an alcoholic, etc. then you should get out that relationship immediately before having children. Therefore, your children will have a happy, healthy, life. 
5 0
3 years ago
Why have countries requested for the removal of content?
Kipish [7]
These links should help u:
https://support.google.com/transparencyreport/answer/7347744?hl=en

https://searchengineland.com/most-censorship-and-content-takedown-requests-come-from-us-says-google-...
5 0
3 years ago
Help me
mestny [16]

Answer:

  1. True
  2. False
  3. False
  4. True
  5. False

Explanation:

mark me as brainlyest

6 0
3 years ago
Please help me for this question - Computer Science
gavmur [86]

Answer:

# F F F F 0 0

# F F 0 0 F F

# 0 0 F F F F

Explanation:

Hex values are your friend.

The first two digits represent red.

# F F 0 0 0 0 - Red

The second two digits represent green.

# 0 0 F F 0 0 - Green

The third two digits represent blue.

# 0 0 0 0 F F - Blue

If you know yellow is a combination of red and green, you express the corresponding digits.

# F F 0 0 0 0 - Red

# 0 0 F F 0 0 - Green

+

-------------------------------

# F F F F 0 0 - Yellow

Similarly,

If you know magenta is a combination of red and blue, you express the corresponding hex digits.

# F F 0 0 0 0 - Red

# 0 0 0 0 F F - Blue

+

-----------------------------

# F F 0 0 F F - Magenta

And finally,

If you know cyan is a combination of green and blue, you express the corresponding hex digits.

# 0 0 F F 0 0 - Green

# 0 0 0 0 F F - Blue

+

----------------------------

# 0 0 F F F F - Cyan

What does it mean to "express the digits"?

If you know anything about how color works on a computer, you'll know that you can express a certain amount of red, green and blue to get almost any color. These are known as "RGB" values. In RGB, the red, green or blue can individually go from 0 - 255. Think of it like a slider for how much you want of each color.

In RGB:

RGB (255, 255, 255) - White

Hex is just a really convenient and shorthand way to write the RGB color values.

In Hex:

#FFFFFF - White

6 0
3 years ago
Other questions:
  • To illustrate a point in a Word document with a simple chart, what command should you select
    6·2 answers
  • Using a wireless network without the network owner's permission is known as ________.
    15·1 answer
  • Explain with a few sentences and using the terms sequencing, selections and loops how they
    9·1 answer
  • You and your project team have been asked to generate a solution to a problem. The problem is not complicated, and you are sure
    6·1 answer
  • A college has 2.3 ratio of men to women in its student body you what is the ratio of women to men
    15·1 answer
  • Explain the difference between invention and innovation?
    13·1 answer
  • A small company with 100 computers has hired you to install a local area network. All of the users perform functions like email,
    9·1 answer
  • Use NAND operator to write; P or Q, and P -Q make an everyday implication sentence using only NAND
    14·1 answer
  • One security component that doubles as a network component
    5·2 answers
  • Wml script is used in? ​
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!