-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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 #1861
base: master
Are you sure you want to change the base?
Solution #1861
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.
Great job on implementing the Car
and CarWashStation
classes! 🎉 Your code meets the task requirements and constraints effectively. There are a couple of minor issues related to type hints that you might want to address for better clarity and compatibility: consider changing the return type of wash_single_car
to float
, and if you're using Python version earlier than 3.9, use List[Car]
from the typing
module instead of list[Car]
. Keep up the good work and happy coding! 😊
✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨
app/main.py
Outdated
self.average_rating = average_rating | ||
self.count_of_ratings = count_of_ratings | ||
|
||
def serve_cars(self, cars: list[Car]): |
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 type hint list[Car]
requires Python 3.9 or later. If you're using an earlier version, consider using List[Car]
from the typing
module.
app/main.py
Outdated
/ self.distance_from_city_center)) | ||
return round(washing_price, 1) | ||
|
||
def wash_single_car(self, car: Car) -> int: |
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 return type of wash_single_car
is specified as int
, but the method actually returns a float value from calculate_washing_price
. Consider changing the return type to float
.
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.
Tests Failed!
self.count_of_ratings = count_of_ratings | ||
|
||
def serve_cars(self, cars: list[Car]) -> int: | ||
income = 0 |
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.
If I were you, I would improve this function by replacing the loop with an additional variable to iterate with the use of the usual sum()
function. This solution will cost us only 1 line of code and its readability will not deteriorate
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.
def serve_cars(self, cars: list[Car]) -> int:
return sum([self.wash_single_car(car) for car in cars])
Something like this?
No description provided.