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
Class members are accessed via the ____(1)_____ operator in conjunction with the name of an object of the class, or via the ___(
Alborosie

Answer:

1.ClassName and . operator

2. ClassName and [] operator

Explanation:

There are two ways to get the members of a class first one is by using dot(.) operator.

Example : with assumption that person is a class object and age is the member in it we can use it as:

person.age

Second way is to use [] operator with member as a string in it which is used by the compiler as key to get its value.

Example : person["age"]

5 0
3 years ago
Which of the following is not a benefit of normalization?
mixer [17]

Answer:

The answer is option (4) Maximize redundancy as normalization minimizes redundancy of data.

Explanation:

Normalization of databases leads to minimization of data redundancy in databases. It doesn't maximize data redundancy. Data redundancy leads to wastage of resources. Normalization of databases minimizes insertion anomolies. Normalization of databases minimizes deletion anomolies. Normalization of databases minimizes updation anomolies.  So , the answer to the question is option (4) maximize redundancy.

8 0
3 years ago
Which header will be the largest?<br><br> Hello<br><br> Hello<br><br> Hello<br><br> Hello
geniusboy [140]

Answer:  

Bye

bye

bye

bye

Explanation:

4 0
2 years ago
Read 2 more answers
Matt expects to get his first paycheck today. What deductions may be listed on his paycheck stub?
Bingel [31]
Social security
Also if he has any taxs they will be deducted
4 0
3 years ago
Everyone interacts with various information systems every day: at the grocery store, at work, at school, even in our cars. Make
Alex73 [517]

Answer:

- RFID tags in shopping mall.

- Browsing the internet.

- Mobile phone calls

Explanation:

Radio frequency identification tag (RFID) in a device that holds personal information of a user electromagnetically. it is used in shopping mall, installed in the shopper's phone or a card, in which all payments are done automatically.

The internet is a global network of devices. With a subscription to a internet service provider, a user can surf the internet at any time of the day.

Mobile phones are portable devices, procured by a user for on-the-go calls. This cell phones have databases with information of cell tower connections, for easy switching for flexible but quality call adaptation.

5 0
3 years ago
Other questions:
  • The protocol that makes it possible for a Macintosh web browser to be able to retrieve a Web page from a Microsoft Web server is
    8·2 answers
  • Which protocol is often used to publish web pages to a web server?
    5·1 answer
  • In python:
    14·1 answer
  • What is an example of a memo
    9·1 answer
  • Help me with this, please. Are vacuum cleaners, Cd players, and telephones considered computers? Do they store any data or proce
    8·2 answers
  • 9. What command do you enter in the Explorer search box to access the Remote Admin share on the computer named Fin?
    7·1 answer
  • The operating system (OS) of an information system contains the software that executes the critical functions of the information
    6·1 answer
  • In design and implementation of any _____ reasoning application, there are 4 Rs involved: retrieve, reuse, revise, and retain.
    7·1 answer
  • Does anyone have Rblx? if so write your username
    6·1 answer
  • Information to develop a project network is collected from the.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!