-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Solution #1675
base: master
Are you sure you want to change the base?
Solution #1675
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"I like reusing method: km = self.add(other).km
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job on implementing the Distance
class! 🎉 Your code meets the task requirements and constraints effectively. While there are some suggestions for improving error messages by adding more context, these are minor enhancements that don't impact the core functionality. Keep up the good work, and consider refining those error messages for even better clarity in the future! 😊
✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨
return Distance(other.km + self.km) | ||
elif isinstance(other, (int, float)): | ||
return Distance(self.km + other) | ||
raise TypeError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The TypeError
should include a message to provide more context about the error. Consider using raise TypeError('Unsupported type for addition')
.
def __mul__(self, other: Union[int, float]) -> Distance: | ||
if isinstance(other, (int, float)): | ||
return Distance(self.km * other) | ||
raise TypeError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The TypeError
should include a message to provide more context about the error. Consider using raise TypeError('Unsupported type for multiplication')
.
def __truediv__(self, other: Union[int, float]) -> Distance: | ||
if isinstance(other, (int, float)): | ||
return Distance(round(self.km / other, 2)) | ||
raise TypeError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The TypeError
should include a message to provide more context about the error. Consider using raise TypeError('Unsupported type for division')
.
return self.km < other.km | ||
elif isinstance(other, (int, float)): | ||
return self.km < other | ||
raise TypeError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The TypeError
should include a message to provide more context about the error. Consider using raise TypeError('Unsupported type for less than comparison')
.
return self.km > other.km | ||
elif isinstance(other, (int, float)): | ||
return self.km > other | ||
raise TypeError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The TypeError
should include a message to provide more context about the error. Consider using raise TypeError('Unsupported type for greater than comparison')
.
return self.km == other.km | ||
elif isinstance(other, (int, float)): | ||
return self.km == other | ||
raise TypeError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The TypeError
should include a message to provide more context about the error. Consider using raise TypeError('Unsupported type for equality comparison')
.
return self.km <= other.km | ||
elif isinstance(other, (int, float)): | ||
return self.km <= other | ||
raise TypeError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The TypeError
should include a message to provide more context about the error. Consider using raise TypeError('Unsupported type for less than or equal comparison')
.
return self.km >= other.km | ||
elif isinstance(other, (int, float)): | ||
return self.km >= other | ||
raise TypeError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The TypeError
should include a message to provide more context about the error. Consider using raise TypeError('Unsupported type for greater than or equal comparison')
.
No description provided.