I need help with completing this python code.Complete the Car class by creating an attribute purchase_price (type int) and the method 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()

Answers

Answer 1

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.


Related Questions

window is a very popular operating system becouse of its _ environment .​

Answers

Window is a vary popular operating system because of its runtime and compatible environment .
hope it help
Windows is perhaps the most popular operating system for personal computers globally. ... Windows is very popular because it is pre-loaded in majority of the new personal computers. Compatibility. A Windows PC is compatible with most software programs in the market

write a technical term for following statements
1.The method applied to increase the life of computer and its assets.
2.The power regulating device this supplies constant power to the computer from its backup system.
3.The software used to scan, locate and detect the disk for viruses.

Answers

Answer:

1. Hardware Maintenance

2. Uninterrupted Power Supply (UPS)

3. Antivirus software

Explanation:

Antivirus software, or Anti-virus software (also known as AV software), otherwise called anti malware, is a PC program used to forestall, distinguish, and eliminate malware.

Antivirus software was initially evolved to identify and eliminate PC infections, thus the name. Be that as it may, with the expansion of different sorts of malware, antivirus software began to give security from other PC dangers. Specifically, current antivirus software can shield clients from: noxious program criminals.

A few items additionally incorporate security from other PC dangers, for example, tainted and noxious URLs, spam, trick and phishing assaults, online identity (privacy), web based financial assaults, social engineering techniques, advanced persistent threat (APT).

Other Questions
2 Efetue: a) (+7) . (- 5) b) (-9) . (- 8) c)(-15) : (+5) d) (+125) : (+25)preciso disso pra agora Why would modern times require a new modern approach to theatrical dance I will give brainless to the first ancer What was unique about the Battle of New Orleans in the War of 1812?A. Andrew Jackson died during it.B. The United States lost the battleC. It occurred in January 1815, after the Treaty of Ghent that ended of the war.D. The U.S. surrendered the city to Britain after the battle.#2 Which conflict was called the "Second American Revolution" by President James Madison?A. The French and Indian WarB. The War of 1812C. The Battle of Lake ErieD. The Battle of New Orleans Describe a real-world example on how coordinate geometry is/can be used in the real-world. Then, create a sample question based on your example for the rest of your classmates to solve. which of the following sentences would most likely be the claim of an argumentative essay Which equation represents a line that passes through the two points in thetable? Dose y = 7.2x represent a proportional relationship, if so identify the constant of proportionality. If not, explain why not. Why did the Second Continental Congress believe it was necessary to form a Continental Army? Please help with some spanish sentences? HELP!!!1 Write 12 sentences using all the words and word combinations.be (not) keen on ...really lovebe really intoprefercan`t standbe interested indon`t mindquite likeenjoybe fond ofcan`t stand/bearadore Ill mark as BRANLIEST!!!45 POINTS!!!I need help with both questions plz help god loves you all. write a paragraph for tissue engineering How do cells maintain homeostasis without using energy 16an - 19an +8b +9an +12 b Mirah has breakfast at a reaturant. She leaves an 20% tip of $1.80 Which statement did Virchow's work add to the cell theory?A. Cells contain genetic material that consists of DNA.O B. The cell is the basic structural and functional unit of life.O C. All living things are made of one or more cells.O D. All cells come from other living cells. HELP ASAP!! WILL TRY TO GIVE BRAINLIESTHow are ribosomes different from other complex animal cell organelles? How are water scarcity and water pollution related?Water pollution contributes to water scarcity.Water pollution is a solution to water scarcity.Water scarcity is a solution to water pollution.Water scarcity contributes to water pollution. Genetics is defined as: Group of answer choices The scientific study of cells The study of cloning The scientific study of heredity The dividing of cells Why do you need air resistance in a parachute ?what happens without it?And How does air resistance affect acceleration and terminal velocity