!8.8 Class customization
"8.10 LAB: Winning team (classes)
8.9 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 cu
ent year, then print_info() outputs:
Car's information:
Model year: 2011
Purchase price: 18000
Cu
ent value: 5770
Note: print_info() should use three spaces for indentation.
XXXXXXXXXXqx3zqy7
LAB
ACTIVITY 8.9.1: LAB: Car value (classes) 0 / 10
Run your program as often as you'd like, before submitting for grading. Below, type any needed
input values in the Rrst box, then click Run program and observe the program's output in the
second box.
Enter program input (optional)
If your code requires input values, provide them here.
Input (from above)#
main.py
(Your program) # Output (shown below)
Program output displayed here
Signature of your work
History of your effort will appear here once you begin working on this zyLab.
ma...py Load default template...
class Car:
def __init__(self):
XXXXXXXXXXself.model_year = 0
# TODO: Declare purchase_price attribute
XXXXXXXXXXself.cu
ent_value = 0
def calc_cu
ent_value(self, cu
ent_year):
XXXXXXXXXXdepreciation_rate = 0.15
# Car depreciation formula
XXXXXXXXXXcar_age = cu
ent_year - self.model_yea
XXXXXXXXXXself.cu
ent_value = round(self.purchase_price * (1 - depreciation_rate) ** car_age)
# TODO: Define print_info() method to output model_year, purchase_price, and cu
ent_value
if __name__ == "__main__":
year = int(input())
Develop mode Submit mode
Run program
What is this?
Feedback?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
My li
ary > IT 140: Introduction to Scripting v3 home > 8.9: LAB: Car value (classes)$ % zyBooks catalog & Help/FAQ Jessica Coupar' (
https:
learn.zybooks.com/zybook/SNHUIT140v3/chapte
8/section/8
https:
learn.zybooks.com/zybook/SNHUIT140v3/chapte
8/section/10
https:
learn.zybooks.com/li
ary
https:
learn.zybooks.com/zybook/SNHUIT140v3
https:
learn.zybooks.com/zybook/SNHUIT140v3/chapte
8/section/9
!8.9 LAB: Car value (classes)
"8.11 Modules
8.10 LAB: Winning team (classes)
Complete the Team class implementation. For the instance method get_win_percentage(), the formula is:
team_wins / (team_wins + team_losses)
Note: Use )oating-point division.
Ex: If the input is:
Ravens
13
3
where Ravens is the team's name, 13 is the number of team wins, and 3 is the number of team losses, the output is:
Congratulations, Team Ravens has a winning average!
If the input is Angels 80 82, the output is:
Team Angels has a losing average.
XXXXXXXXXXqx3zqy7
LAB
ACTIVITY 8.10.1: LAB: Winning team (classes) 0 / 10
Run your program as often as you'd like, before submitting for grading. Below, type any needed
input values in the Srst box, then click Run program and observe the program's output in the
second box.
Enter program input (optional)
If your code requires input values, provide them here.
Input (from above)#
main.py
(Your program) # Output (shown below)
Program output displayed here
Signature of your work
History of your effort will appear here once you begin working on this zyLab.
ma...py Load default template...
class Team:
def __init__(self):
XXXXXXXXXXself.team_name = 'none'
XXXXXXXXXXself.team_wins = 0
XXXXXXXXXXself.team_losses = 0
# TODO: Define get_win_percentage()
if __name__ == "__main__":
team = Team()
team_name = input()
team_wins = int(input())
team_losses = int(input())
team.team_name = team_name
Develop mode Submit mode
Run program
What is this?
Feedback?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
My li
ary > IT 140: Introduction to Scripting v3 home > 8.10: LAB: Winning team (classes)$ % zyBooks catalog & Help/FAQ Jessica Coupar' (
https:
learn.zybooks.com/zybook/SNHUIT140v3/chapte
8/section/9
https:
learn.zybooks.com/zybook/SNHUIT140v3/chapte
8/section/11
https:
learn.zybooks.com/li
ary
https:
learn.zybooks.com/zybook/SNHUIT140v3
https:
learn.zybooks.com/zybook/SNHUIT140v3/chapte
8/section/10