''' DS2000 Fall 2024 Sample code from lecture - class for a TV Show Focus on attributes that are numeric ''' RATING_THRESHOLD = 9 SCALE_THRESHOLD = 2 TIME_THRESHOLD = 10 class TVShow: ''' TV Show class to use for recommendations Attributes: rating, tone, trope, length, num eps, year Methods: init, str, recommend PLEASE DO TRACE! :) ''' def __init__(self, title, rating, tone, trope, length = 30, episodes = 20, year = 2024): self.title = title self.rating = int(rating) self.tone = float(tone) self.trope = float(trope) self.length = int(length) self.episodes = int(episodes) self.year = year def __str__(self): ''' to print a TVShow object, just use the title''' return self.title def recommend(self, other): ''' recommendation method using only yes/no recommend this show (self) if: (1) it has a pretty good rating (2) it's similar in trope and tone attributes to other ''' if self.rating < RATING_THRESHOLD: return False if abs(self.trope - other.trope) < SCALE_THRESHOLD: if abs(self.tone - other.tone) < SCALE_THRESHOLD: return True return False