subject

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.
This is what is given
class Car:
def __init__(self):
self. model_year = 0
# TODO: Declare purchase_price attribute

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

if __name__ == "__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()

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 22:10
Asequential circuit contains a register of four flip-flops. initially a binary number n (0000 ≤ n ≤ 1100) is stored in the flip-flops. after a single clock pulse is applied to the circuit, the register should contain n + 0011. in other words, the function of the sequential circuit is to add 3 to the contents of a 4-bit register. design and implement this circuit using j-k flip-flops.
Answers: 1
question
Computers and Technology, 22.06.2019 23:30
Select all that apply. which of the following are proofreading options included in microsoft word? spell check find replace grammar check formatting check
Answers: 1
question
Computers and Technology, 24.06.2019 12:50
Write a new lc-3 trap subroutine (i.e. a subroutine that will be invoked via the trap instruction) that will receive a numeric digit entered at the keyboard (i.e. an ascii character), echo it to the screen, and return in r0 the corresponding numeric value: so if the user types the digit '7', the character '7' will appear on the screen, but the value returned in r0 will be b0000 0000 0000 0111 (#7) you may not use any trap calls in your code - you must implement the "polling" code that interrogates the keyboard status and data registers. ; getnum_tsr ; a subroutine for obtaining a numeric value ; given ascii numeric digit input to keyboard. ; the numeric digit is echoed to the console (e.g. '7' = b0000 0000 0011 0111), ; but the value returned in r0 is the actual numeric value ; corresponding to the digit (e.g. b0000 0000 0000 0111 =
Answers: 3
question
Computers and Technology, 25.06.2019 08:20
With technology, information is sent to users based on their previous inquiries, interests, or specifications.
Answers: 2
You know the right answer?
Complete the Car class by creating an attribute purchase_price (type int) and the method print_info(...
Questions
question
Mathematics, 24.02.2021 19:20
question
Mathematics, 24.02.2021 19:20
question
Mathematics, 24.02.2021 19:20