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
Alex787 [66]
3 years ago
14

I need help with completing this python code.Complete the Car class by creating an attribute purchase_price (type int) and the m

ethod print_info() that outputs the car's information.Ex: If the input is:2011180002018where 2011 is the car's model year, 18000 is the purchase price, and 2018 is the current year, then print_info() outputs:Car's information: Model year: 2011 Purchase price: 18000 Current value: 5770Note: print_info() should use three spaces for indentation.class Car:def __init__(self):self.model_year = 0# TODO: Declare purchase_price attributeself.current_value = 0def calc_current_value(self, current_year):depreciation_rate = 0.15# Car depreciation formulacar_age = current_year - self.model_yearself.current_value = round(self.purchase_price * (1 - depreciation_rate) ** car_age)# TODO: Define print_info() method to output model_year, purchase_price, and current_valueif __name__ == "__main__":year = int(input())price = int(input())current_year = int(input())my_car = Car()my_car.model_year = yearmy_car.purchase_price = pricemy_car.calc_current_value(current_year)my_car.print_info()
Computers and Technology
1 answer:
netineya [11]3 years ago
4 0

Answer:

class Car:

   def __init__(self):

       self.model_year = 0

       # TODO: Declare purchase_price attribute

       self.purchase_price = 0

       self.current_value = 0

   def calc_current_value(self, current_year):

       depreciation_rate = 0.15

       # Car depreciation formula

       car_age = current_year - self.model_year

       self.current_value = round(self.purchase_price * (1 - depreciation_rate) ** car_age)

# TODO: Define print_info() method to output model_year, purchase_price, and current_value

   def print_info(self):

       print("Model year: ",self.model_year)

       print("Purchase year: ",self.purchase_price)

       print("Current value: ",self.current_value)

def main():

   year = int(input())

   price = int(input())

   current_year = int(input())

   my_car = Car()

   my_car.model_year = year

   my_car.purchase_price = price

   my_car.calc_current_value(current_year)

   my_car.print_info()

if __name__ == "__main__":

   main()

Explanation:

The Car class in the python program is used to create a car object instance with class methods model_year, purchase_price, and calc_current_value, which accepts as arguments, year, price and current_year respectively. The main function runs if only the python module is run and interpreted to print out the year and current price of a car object instance defined.

You might be interested in
Which tag you will use to explain a set of in an HTML document?
Ahat [919]

Answer:

<p> </p>

Explanation:

3 0
3 years ago
Smart phones and Smart watches are same functions due to?
Fantom [35]

Answer:Their motherboards,battery packs and circuits.

Mother boards are green tech plates that help connect and make a device work,they have sod (melted metal) to hold wires and buttons to it.

6 0
3 years ago
Technician A states that a tap handle has a right-angled jaw that matches the squared end that all taps have. Technician B state
Elena L [17]

Answer:

Technician A and Technician B are correct

Explanation:

Based on the information provided within the question it can be said that both Technician A and Technician B are correct. A tap handle's right-angled jaw allows many different taps to be attached for different types of situation to more comfortably and conveniently handle that situation. Such as a T-shaped tap in order to cut a thread in an awkward space as Technician B has stated.

3 0
3 years ago
Hyperlinks are a part of an HTML element called a(n) _____.
Lyrx [107]

The Anchor element.

HTML element (or anchor element), with its href attribute, creates a hyperlink to web pages, files, email addresses, locations in the same page, or anything else a URL can address. Content within each <a> should indicate the link's destination.

6 0
2 years ago
Read 2 more answers
Which printing method transfers the ink from a metal plate to a rubber blanket?
gizmo_the_mogwai [7]

Answer:

B. Offset printer is the correct answer

7 0
3 years ago
Other questions:
  • Alex is setting up a network for his company's computers. He installs a circuit board into each computer, enabling it to be conn
    15·1 answer
  • A graphic design student is putting the finishing touches on her PowerPoint presentation for her speech. She is carefully analyz
    12·1 answer
  • Plz help me of this answer<br><br><br>language:python​
    7·2 answers
  • In addition to regular watch features, which two features are often found on smart watches?
    10·1 answer
  • Which Boolean operator produces the result 1 only if both values are 1? Which Boolean operator produces the result 0 only if bot
    13·1 answer
  • AI in processing capability of computer yes or no​
    13·2 answers
  • Claire writes a letter to her grandmother, in which she describes an amusement park she visited last week. She adds pictures of
    13·1 answer
  • Switched backbone networks:_____.a. always use a ring topology.b. require much more management that do routed backbone networks.
    10·1 answer
  • A debate about city schools are more better than village schools​
    8·1 answer
  • Soa contains a lot of benefits, but _________ is not considered one of them.
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!