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
11What is the definition of bandwidth? the speed at which bits travel on the network the measure of the transfer of bits across
DIA [1.3K]

Answer:the transmission capacity of an electronic communications device or system; the speed of data transfer

Explanation:

8 0
3 years ago
What do you think is the most fascinating aspect of the internet
kari74 [83]
The 20th century seemed to be the year of a complete freedom once the Internet has been spread worldwidely. Unfortunately, it only seemed to be a trial to see various reactions. The 21st century will change this gradually.
6 0
2 years ago
Which one of the following report sections appear once on every report page?
Elina [12.6K]

Answer: Page footer section

Explanation:

 Page footer section is basically appear in the each report page at the bottom of the page. The page footer is basically used for the page number and the brief explanation of the symbols.

On the other hand, Report header section is basically appear once in the beginning of the report.

Report footer section is basically appear once in the end of the report.

Detail section is basically used to display the all detailed information in the report.

Therefore, page footer section is the correct option.

6 0
2 years ago
List the different generation of computers with its main component​
Dennis_Churaev [7]

Answer:

1940 – 1956:  First Generation

1956 – 1963: Second Generation

1964 – 1971: Third Generation

1972 – 2010: Fourth Generation

2010-  : (Present )Fifth Generation

Explanation:

  1. First Generation Computers (1940-1956):In this Generation the main component of computers were Vacuum Tubes.
  2. Second Generation Computers (1956-1963):In this generation the main component of computers were Transistors.
  3. Third Generation Computers (1964-1971):In this generation the main component of computers were Integrated Circuits.
  4. Fourth Generation Computers (1972-2010):In this generation the main component of computers were Microprocessor
  5. Fifth Generation (2010-Present):In this generation the main component of computers is Artificial Intelligence
4 0
3 years ago
Windows 1.0 was not considered to be a "true" operating system but rather an operating environment because _____.
Nimfa-mama [501]

Answer:

it providrd a shell for MS-DOS

Explanation:

It basically was a shell to make MS-DOS different. MS-DOS was still the underlying operating system.

3 0
3 years ago
Other questions:
  • Fill the validateForm function to check that the phone number contains a number (use the isNaN function) and that the user name
    10·1 answer
  • Which network could NOT carry commercial traffic?
    15·1 answer
  • How do I get diffrent ranks?
    9·1 answer
  • Select the correct answer from each drop-down menu. Which IF formulas are valid? _____ and _____ are valid IF formulas.
    6·1 answer
  • Which would be the most appropriate way to estimate -6.1(0.22)? Check all that apply.
    9·2 answers
  • Which is the most common way to install memory in a laptop?
    14·1 answer
  • How can you assess a website for currency?
    14·2 answers
  • The term structure, as it relates to programming, refers to the decisions you make to design your program to best meet its objec
    11·1 answer
  • PLEASE HELP!!! THIS IS DUE TODAY! WILL MARK BRAINLIEST!
    5·1 answer
  • Identify the calculation performed by the following code.
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!