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
A program written in a(n) procedural language consists of sequences of statements that manipulate data items. __________________
Alenkasestr [34]

Answer:

true.

Explanation:

According to my research on information technology, I can say that based on the information provided within the question the statement is completely true. Procedural programming is a widely used paradigm that basically gives the program a set of routines or specifications, and the program mixes and matches them as they continuously repeat the process. It is used in many areas, including video game development.

I hope this answered your question. If you have any more questions feel free to ask away at Brainly.

7 0
3 years ago
What is the organizational management practices on planning during a pandemic like corona virus.
eduard

Answer:

wear a mask use hand sanitizer dont get in contact with anyone between 6 feet

Explanation:

3 0
3 years ago
20 points
adoni [48]
Yes it's important. It's like taking jotting down the ideas you have for a project, you don't want to forget anything, and these things help you keep track of what you want to do.

Answer would be false.
4 0
3 years ago
Open punctuation means that no punctuation follows the salutation or complimentary close. *
zloy xaker [14]

Answer:

True

Explanation:

When open punctuation is used, we do not expect the use of punctuation after salutation or complimentary close. It is a relatively new concept in business writing and we can rightly use this method in modified block letter style of writing.  

Some companies have developed business letter templates that are arranged in an open style, which permits the use of open punctuation in all aspect of business writings.  

7 0
3 years ago
TRUE OR FALSE! A query can have no more than three common interpretations.
Vanyuwa [196]

A query can have no more than three common interpretations is false. A query is a search through a source to find the answer to something. A common interpretation are the items that pop up in in the first spots of the search query because they are the most relatable to the question. A common interpretation usually answers the question, but there are times that the question is more complex and needs to be search for longer within the sources that pop up.

8 0
3 years ago
Other questions:
  • Ally made the net below to find the surface area of a box she was designing. The box measures 12 centimeters long by 9 centimete
    7·1 answer
  • When using a wireless mouse, what is the most common port used for the transmitter? 
    7·1 answer
  • A stack is initially empty, then the following commands are performed: push 5, push 7, pop, push 10, push 5, pop, which of the f
    8·1 answer
  • Which statement best describes the Tell Me feature in PowerPoint 2016?
    8·1 answer
  • Your motherboard supports dual channeling and you currently have two slots populated with DIMMs; each module holds 2 GB. You wan
    6·2 answers
  • A subroutine may be used to refer to which of the following? Check all that apply.
    15·2 answers
  • what social media application that affect our day to day activities, and how did it improve our skill
    9·1 answer
  • Write a SELECT statement that returns a single value that represents the sum of the largest unpaid invoices submitted by each ve
    5·1 answer
  • 3. Choose the statement that best describes a ray. A ray extends forever in both directions. B ray is a part of a line with two
    10·1 answer
  • I Previous
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!