MCPcopy Create free account
hub / github.com/bslatkin/effectivepython / Rating

Class Rating

example_code/item_081.py:94–104  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

92 pass
93
94class Rating:
95 def __init__(self, max_rating):
96 if not (max_rating > 0):
97 raise RatingError("Invalid max_rating")
98 self.max_rating = max_rating
99 self.ratings = []
100
101 def rate(self, rating):
102 if not (0 < rating <= self.max_rating):
103 raise RatingError("Invalid rating")
104 self.ratings.append(rating)
105
106
107print("Example 6")

Callers 1

item_081.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected