week-8 #13

Merged
Kenwood merged 4 commits from week-8 into master 2021-02-27 13:10:58 -05:00
4 changed files with 94 additions and 0 deletions

27
8/8.10 LAB/main.py Normal file
View File

@ -0,0 +1,27 @@
class Team:
def __init__(self):
self.team_name = 'none'
self.team_wins = 0
self.team_losses = 0
self.win_percentage = 0
def get_win_percentage(self):
return self.team_wins / (self.team_wins + self.team_losses)
if __name__ == "__main__":
team = Team()
team_name = input()
team_wins = int(input())
team_losses = int(input())
team.team_name = team_name
team.team_wins = team_wins
team.team_losses = team_losses
if team.get_win_percentage() >= 0.5:
print('Congratulations, Team', team.team_name,'has a winning average!')
else:
print('Team', team.team_name, 'has a losing average.')

24
8/8.6/8.6.1/main.py Normal file
View File

@ -0,0 +1,24 @@
class PhonePlan:
# FIXME add constructor
def __init__(self, _num_mins=0, _num_messages=0):
self.num_mins = _num_mins
self.num_messages = _num_messages
def print_plan(self):
print('Mins:', self.num_mins, end=' ')
print('Messages:', self.num_messages)
my_plan = PhonePlan(int(input()), int(input()))
dads_plan = PhonePlan()
moms_plan = PhonePlan(int(input()))
print('My plan...', end=' ')
my_plan.print_plan()
print('Dad\'s plan...', end=' ')
dads_plan.print_plan()
print('Mom\'s plan...', end= ' ')
moms_plan.print_plan()

15
8/8.8/8.8.1/main.py Normal file
View File

@ -0,0 +1,15 @@
class CarRecord:
def __init__(self):
self.year_made = 0
self.car_vin = ''
# FIXME add __str__()
def __str__(self):
return'Year: {0}, VIN: {1}'.format(self.year_made, self.car_vin)
my_car = CarRecord()
my_car.year_made = int(input())
my_car.car_vin = input()
print(my_car)

28
8/8.9 LAB/main.py Normal file
View File

@ -0,0 +1,28 @@
class Car:
def __init__(self):
self.model_year = 0
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)
def print_info(self):
return """Car's information:
Model year: {0}
Purchase price: {1}
Current value: {2}""".format(self.model_year, self.purchase_price, self.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)
print(my_car.print_info())