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: 2011 18000 2018 where 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: 5770 Note: print_info( should use three spaces for indentation.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Need help solving this code in python

9.11 LAB: Car value (classes)
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:
2011
18000
2018
where 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: 5770
Note: print_info() should use three spaces for indentation.
345892.2051704.qx3zqy7
Transcribed Image Text:9.11 LAB: Car value (classes) 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: 2011 18000 2018 where 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: 5770 Note: print_info() should use three spaces for indentation. 345892.2051704.qx3zqy7
class Car:
def _init_(self):
self.model_year
# TODO: Declare purchase_price attribute
self.current_value = e
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,
rchase_price, and current_value
if
_main_":
int (input())
int(input())
current_year = int(input())
name
year
price
my_car = Car(()
my_car.model_year
my_car.purchase_price = price
my_car.calc_current_value (current_year)
my_car.print_info()
%3D
year
%3D
%3D
Transcribed Image Text:class Car: def _init_(self): self.model_year # TODO: Declare purchase_price attribute self.current_value = e 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, rchase_price, and current_value if _main_": int (input()) int(input()) current_year = int(input()) name year price my_car = Car(() my_car.model_year my_car.purchase_price = price my_car.calc_current_value (current_year) my_car.print_info() %3D year %3D %3D
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY