Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
13cf154
Initial commit
MasterpieceElbow Jan 18, 2022
08d54c1
Init
MasterpieceElbow Jan 18, 2022
4440bbb
Edited
MasterpieceElbow Jan 18, 2022
74beef4
edited
MasterpieceElbow Jan 18, 2022
871c268
Merge pull request #1 from mate-academy/python-add-car-wash-station-g…
MasterpieceElbow Jan 18, 2022
1dd8c9b
add exclude venv and tests in .flake8
Abnormaltype May 3, 2022
a03f6a1
Merge pull request #25 from mate-academy/py_car_wash_station_upd_flake
Abnormaltype May 3, 2022
806831d
fix readme.md
Abnormaltype May 11, 2022
5472593
Merge pull request #29 from mate-academy/fix_readme
Abnormaltype May 11, 2022
dda2a4c
add timeout on tests
Abnormaltype Jun 9, 2022
e80085c
Merge pull request #74 from mate-academy/add_timeout
Abnormaltype Jun 9, 2022
2392e6e
Update test.yml
Abnormaltype Jun 10, 2022
06d531d
checklist and test for coment added
DmytroSvirsa Sep 6, 2022
5a44a08
description to rate_service and serve_cars methods added
Sep 6, 2022
7feed3f
Merge pull request #152 from mate-academy/detailed_descriptions_added…
Y-Havryliv Sep 6, 2022
b53c403
Update .flake8
MasterpieceElbow Sep 16, 2022
a07cd98
test added
DmytroSvirsa Sep 19, 2022
5eca31a
Merge pull request #151 from mate-academy/add-checklist
DmytroSvirsa Sep 19, 2022
00e88af
Update test_main.py
DmytroSvirsa Sep 19, 2022
2940476
Update .flake8
danylott Oct 5, 2022
d1b6594
Update requirements.txt
danylott Oct 5, 2022
c418a39
Update README.md
Y-Havryliv Feb 23, 2023
ee215a2
Update test.yml
ihor-jpeg Aug 28, 2023
16d8349
Update test.yml
ihor-jpeg Aug 29, 2023
3723e54
Додаю Python-проєкти до pull request
Vitrikus Apr 30, 2025
5185c7d
Вирішені конфлікти під час merge
Vitrikus May 9, 2025
7a7cbdd
Оновлено код: виправлення імпорту та тестів
Vitrikus May 10, 2025
520beed
Виключено системні файли з відстеження
Vitrikus May 10, 2025
c2329ec
Додано винятки у .gitignore
Vitrikus May 10, 2025
aa6766b
Виправлено IndentationError та вирівнювання
Vitrikus May 10, 2025
c679780
Виправлено E302 та E305 (форматування рядків)
Vitrikus May 10, 2025
bbf7b9d
Виправлено F811, E302, E305 у CarWashStation
Vitrikus May 10, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ jobs:
steps:
- name: Checkout repo
uses: actions/checkout@v2


Comment on lines +15 to +16
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

There is an empty step here. Please remove these lines as they do not serve any purpose and may cause YAML parsing errors.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

пусті рядки забрані їх немає

- name: Set Up Python 3.10
uses: actions/setup-python@v2
with:
Expand All @@ -21,6 +23,7 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt

- name: Run flake8
run: flake8 app/
- name: Run tests
Expand Down
30 changes: 30 additions & 0 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Test

on:
pull_request:
branches:
- "master"

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout repo
uses: actions/checkout@v2

- name: Set Up Python 3.10
uses: actions/setup-python@v2
with:
python-version: "3.10"

- name: Install pytest and flake8
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt

- name: Run flake8
run: flake8 app/
- name: Run tests
timeout-minutes: 5
run: pytest tests/
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,13 @@
.DS_Store
venv/
.pytest_cache/
<<<<<<< HEAD
**__pycache__/
=======
>>>>>>> upstream/master
Comment on lines +8 to +11
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

There is a merge conflict here. Please resolve the conflict by choosing the correct lines to keep and removing the conflict markers (<<<<<<<, =======, >>>>>>>).

AppData/
Cookies/
Templates/
AppData/
Local Settings/
NTUSER.DAT*
146 changes: 146 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,148 @@
Read [the guideline](https://github.com/mate-academy/py-task-guideline/blob/main/README.md) before starting.

You own a car washing station. Washing cost calculation
takes a lot of time, and you decide to automate this
calculation. The washing cost will depend on car comfort
class, car cleanness degree, wash station average rating
and wash station distance from the center of the city.

Create class `Car`, its `__init__` method takes and stores
3 arguments:
1. `comfort_class` - comfort class of a car, from 1 to 7
2. `clean_mark` - car cleanness mark, from very
dirty - 1 to absolutely clean - 10
3. `brand` - brand of the car

Create class `CarWashStation`, its `__init__` method takes and
stores 4 arguments:
1. `distance_from_city_center` - how far station from
the city center, from 1.0 to 10.0
2. `clean_power` - `clean_mark` to which this car wash station
washes (yes, not all stations can clean your car completely)
3. `average_rating` - average rating of the station,
from 1.0 to 5.0, rounded to 1 decimal
4. `count_of_ratings` - number of people who rated

`CarWashStation` should have such methods:
1. `serve_cars` - method, that takes a list of `Car`'s, washes only
cars with `clean_mark` < `clean_power` of wash station
and returns income of `CarWashStation` for serving this list of Car's,
rounded to 1 decimal:

```python
bmw = Car(comfort_class=3, clean_mark=3, brand='BMW')
audi = Car(comfort_class=4, clean_mark=9, brand='Audi')

print(bmw.clean_mark) # 3

wash_station = CarWashStation(
distance_from_city_center=5,
clean_power=6,
average_rating=3.5,
count_of_ratings=6
)

income = wash_station.serve_cars([bmw, audi])

print(income) # 6.3
print(bmw.clean_mark) # 6
```

So, only bmw was washed, because `audi.clean_mark` > `wash_station.clean_power`,
and `bmw.clean_mark` has changed, because we washed it.

If `audi.clean_mark` was below `wash_station.clean_power` then `audi` would have been washed as well
and the income would have raised:

```python
bmw = Car(comfort_class=3, clean_mark=3, brand='BMW')
audi = Car(comfort_class=4, clean_mark=2, brand='Audi')

print(bmw.clean_mark) # 3
print(audi.clean_mark) # 2

wash_station = CarWashStation(
distance_from_city_center=5,
clean_power=6,
average_rating=3.5,
count_of_ratings=6
)

income = wash_station.serve_cars([bmw, audi])

print(income) # 17.5

print(bmw.clean_mark) # 6
print(audi.clean_mark) # 6
```

2. `calculate_washing_price` - method, that calculates cost for a
single car wash,
cost is calculated as: car's comfort class * difference between
wash station's clean power and car's clean mark * car wash station
rating / car wash station
distance to the center of the city, returns number rounded
to 1 decimal;
3. `wash_single_car` - method, that washes a single car, so it should
have `clean_mark` equals wash station's `clean_power`, if
`wash_station.clean_power` is greater than `car.clean_mark`;
4. `rate_service` - method that adds a single rate to the wash station, and based on this single rate
`average_rating` and `count_of_ratings` should be changed:

```python
wash_station = CarWashStation(
distance_from_city_center=6,
clean_power=8,
average_rating=3.9,
count_of_ratings=11
)

print(wash_station.average_rating) # 3.9
print(wash_station.count_of_ratings) # 11

wash_station.rate_service(5)

print(wash_station.average_rating) # 4.0
print(wash_station.count_of_ratings) # 12
```

You can add own methods if you need.

Example:
```python
bmw = Car(3, 3, 'BMW')
audi = Car(4, 9, 'Audi')
mercedes = Car(7, 1, 'Mercedes')

ws = CarWashStation(6, 8, 3.9, 11)

income = ws.serve_cars([
bmw,
audi,
mercedes
])

income == 41.7

bmw.clean_mark == 8
audi.clean_mark == 9
mercedes.clean_mark == 8
# audi wasn't washed
# all other cars are washed to '8'

ford = Car(2, 1, 'Ford')
wash_cost = ws.calculate_washing_price(ford)
# only calculating cost, not washing
wash_cost == 9.1
ford.clean_mark == 1

ws.rate_service(5)

ws.count_of_ratings == 12
ws.average_rating == 4.0
```

### Note: Check your code using this [checklist](checklist.md) before pushing your solution.
# Mutable and Immutable

- Read [the guideline](https://github.com/mate-academy/py-task-guideline/blob/main/README.md) before start
Expand All @@ -21,3 +166,4 @@ sorted_variables = {
"immutable": [a, c]
}
```
upstream/master
15 changes: 14 additions & 1 deletion app/main.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
class Car:
def __init__(self, brand: str, model: str, year: int) -> None:
self.brand = brand
self.model = model
self.year = year


class CarWashStation:
def wash_single_car(self, car: Car) -> float:
return 10.0


lucky_number = 777
pi = 3.14
one_is_a_prime_number = False
Expand All @@ -16,4 +28,5 @@
}
collection_of_coins = {1, 2, 25}

# write your code here
print(profile_info)
print(collection_of_coins)
80 changes: 80 additions & 0 deletions checklist.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Check Your Code Against the Following Points

## Code Style

1. If you have some long math, you can split it onto additional variables,
or break after binary operations (not before - it cause the W504 errors)

Good example:

```python
fuel_consumption = max_fuel_consumption * height_fuel_consumption_coeficient
estimated_speed = plan_max_speed - wind_awerage_speed * wind_angle_coefisient
estimated_time = distance_to_the_destinatoin / estimated_speed
how_much_fuel_needed = fuel_consumption * estimated_time * overlap_coeficient
```

Good example:

```python
how_much_fuel_needed = (max_fuel_consumption
* height_fuel_consumption_coeficient
* distance_to_the_destinatoin
/ (plan_max_speed
- wind_awerage_speed
* wind_angle_coefisient)
* overlap_coeficient)
```

Bad example:

```python
how_much_fuel_needed = max_fuel_consumption \
* height_fuel_consumption_coeficient \
* distance_to_the_destinatoin / (
plan_max_speed
- wind_awerage_speed
* wind_angle_coefisient
) * overlap_coeficient
```

2. Use descriptive and correct variable names.

Good example:

```python
def get_full_name(first_name: str, last_name: str) -> str:
return f"{first_name} {last_name}"
```

Bad example:
```python
def get_full_name(x: str, y: str) -> str:
return f"{x} {y}"
```

## Clean Code

1. You can avoid else when have return statement.

Good example:

```python
def is_adult(age: int) -> str:
if age >= 18:
return "adult"
return "not an adult"
```

Bad example:

```python
def is_adult(age: int) -> str:
if age >= 18:
return "adult"
else:
return "not an adult"
```

2. Add comments, prints, and functions to check your solution when you write your code.
Don't forget to delete them when you are ready to commit and push your code.
1 change: 1 addition & 0 deletions py-count-occurrences
Submodule py-count-occurrences added at 5c3913
1 change: 1 addition & 0 deletions py-linter-formatter
Submodule py-linter-formatter added at 232325
1 change: 1 addition & 0 deletions py-mutable-immutable
Submodule py-mutable-immutable added at b9a8d0
Loading
Loading