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' #1222

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

'Solution' #1222

wants to merge 3 commits into from

Conversation

KrenkySpenky
Copy link

No description provided.

Copy link

@Dimosphen1 Dimosphen1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Several changes were requested

app/main.py Outdated
Comment on lines 25 to 28
def __init__(self,
name: str,
is_hungry: bool = True
) -> None:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Place each argument including self on a new line so that there would be no arguments on the same line with opening and closing parenthesis here and in the Dog class as well. It will help to improve the code style and readability

app/main.py Outdated
print(f"Eating {self.appetite} food points...")
self.is_hungry = False
return self.appetite
else:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need for else since the code will not execute after the return statement anyway. Please, remove the redundant else

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

app/main.py Outdated
def __init__(
self,
name: str,
appetite: float,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

appetite could be int as well, add it to the type annotation

app/main.py Outdated
Comment on lines 50 to 54
total_food_points = 0
for animal in animals:
if animal.is_hungry:
total_food_points += animal.feed()
return total_food_points

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implement this method in one line using sum. There is no need to check if animal is hungry here since it is done in the feed method

Copy link

@Dimosphen1 Dimosphen1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Several changes were requested

app/main.py Outdated
Comment on lines 20 to 21
else:
return 0

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, remove the redundant else and leave the return statement

Suggested change
else:
return 0
return 0

app/main.py Outdated


def feed_animals(animals: list[Animal]) -> int:
return sum(animal.feed() for animal in animals if animal.is_hungry)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need to perform the if check here, it is already done in the feed method

Suggested change
return sum(animal.feed() for animal in animals if animal.is_hungry)
return sum(animal.feed() for animal in animals)

Copy link

@Dimosphen1 Dimosphen1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, well done!

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.

2 participants