Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Solution #1675

wants to merge 1 commit into from

Conversation

Nikita-pyth
Copy link

No description provided.

Copy link

@kram3ko kram3ko left a 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

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a 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

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

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

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

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

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

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

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

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').

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants