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]
2 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]2 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
What is contrast (in Photography)?
kozerog [31]

Answer:

Contrast is a tool that photographers use to direct viewers' attention to their subject. There are two types: Tonal Contrast and Color Contrast. TC refers to the difference in tones from the lightest tone to the darkest tone, in other words, the difference in tones from white to gray to black.

Explanation:

heheh there you go

3 0
3 years ago
Every information systems (is) user has the right to a secure computing environment. this means that the
Arturiano [62]
<span>Every information systems (IS) user has the right to a secure computing environment. this means that the </span>organization should protect his/her computer and its files.
5 0
3 years ago
What acronym describes networked devices that contain microcomputers but are not thought of as computing devices, such as refrig
vivado [14]
The acronym RFID (Radio Frequency Identification) describes networked devices that contain microcomputers but are not thought of as computing devices, such as refrigerators, automobile components, light bulbs, and industrial control devices. RFIDs are  battery-powered sensors that gather and transmit data to a reading device. Some sensor based technologies are  scanning electron microscopes, LiDAR,radar, GPS, x-ray, sonar, infrared and seismic.



5 0
3 years ago
Why are the keys on the qwerty keyboard arranged the way they are?
sveticcg [70]
Sholes arranged the keys in their odd fashion to prevent jamming on mechanical typewriters by separating commonly used letter combinations.
7 0
2 years ago
Which of the following is an example of a stereotype?
amm1812

Answer:

d)"I have a really bad feeling about her. I don't know why."

Explanation:

5 0
2 years ago
Other questions:
  • How can you tell that a website is valid and reliable
    7·2 answers
  • The ____ algorithm was the first public key encryption algorithm developed (in 1977 and published for commercial use.
    8·1 answer
  • Select the recommended design practice that applies to a web site using images for main site navigation.
    7·1 answer
  • (15 POINTS) When an error is made in HTML code, the browser does what?
    11·1 answer
  • On which of the following pointing devices can you control the pointer by sliding your fingertip?
    11·1 answer
  • Type 1 hypervisor:
    10·1 answer
  • Among the second generation home console companies,which managed to come out on top
    10·1 answer
  • How many megapixels is in a macbook air 2017 camera
    10·1 answer
  • What is Stefen Salvators mom name? For the tvd fans
    12·2 answers
  • What symbol should you look for to determine who owns the intellectual property of a website? the logo the web address the domai
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!