-
Notifications
You must be signed in to change notification settings - Fork 0
level_1 is done #1
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| venv/ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,5 +14,6 @@ def __init__(self, name: str, username: str, age: int, phone: str): | |
|
|
||
|
|
||
| if __name__ == '__main__': | ||
| pass # код писать тут | ||
| new_user = User(name="Human", username="Towel", age=22, phone="+7(999)999-99-99") | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
| print(f"Информация о пользователе:\nИмя - {new_user.name}.\nЛогин - {new_user.username}.\nВозраст - {new_user.age}.\nМобильный телефон - {new_user.phone}.") | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 еще можно сделать метод |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,5 +18,6 @@ def get_full_name(self): | |
|
|
||
|
|
||
| if __name__ == '__main__': | ||
| pass # код писать тут | ||
|
|
||
| student = Student(name='Mark', surname='Proskurin', faculty='Python Development', course=2) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
| get_full_student_name = student.get_full_name() | ||
| print(get_full_student_name) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,8 +9,13 @@ | |
|
|
||
|
|
||
| class Product: | ||
| pass # код писать тут | ||
| def __init__(self, name: str, description: str, price: int, weight: int): | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 в целом все верно |
||
| self.name = name | ||
| self.description = description | ||
| self.price = price | ||
| self.weight = weight | ||
|
|
||
|
|
||
| if __name__ == '__main__': | ||
| pass # код писать тут | ||
| product = Product(name='Chair', description='Very comfortable office chair', price='300$', weight=22) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔴 price у нас в аннотации указан как |
||
| print(f"Information about product:\nName - {product.name}.\nDescription - {product.description}.\nPrice - {product.price}.\nWeight - {product.weight} lb. ") | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,8 +15,10 @@ def __init__(self, owner_full_name: str, balance: float): | |
| self.balance = balance | ||
|
|
||
| def increase_balance(self, income: float): | ||
| pass # код писать тут | ||
|
|
||
| self.balance += income | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 задай аннотацию на возвращаемое значение, используй |
||
|
|
||
| if __name__ == '__main__': | ||
| pass # код писать тут | ||
| bank_account = BankAccount(owner_full_name='User Name', balance=1200.91) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 все верно |
||
| print(f'Баланс счёта: {bank_account.balance}') | ||
| bank_account.increase_balance(259.22) | ||
| print(f'Ваш баланс после пополнения: {bank_account.balance}') | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,8 +10,27 @@ | |
|
|
||
|
|
||
| class BankAccount: | ||
| pass # код писать тут | ||
| def __init__(self, owner_full_name: str, balance: float): | ||
| self.owner_full_name = owner_full_name | ||
| self.balance = balance | ||
|
|
||
| def increase_balance(self, income: float): | ||
| self.balance += income | ||
|
|
||
| def decrease_balance(self, expense: float): | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 указывай аннотации типов на выходное значение, иначе непонятно, либо функция ниче не возращает, либо забыли указать аннотацию |
||
| if self.balance - expense < 0: | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 абсолютно верно, не трогаем баланс, пока не уверены что можем с него списать заданную сумму |
||
| raise ValueError('На вашем счёте недостаточно средств') | ||
| self.balance -= expense | ||
|
|
||
|
|
||
| if __name__ == '__main__': | ||
| pass # код писать тут | ||
| account = BankAccount('Name User', 1000.0) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 все верно |
||
| account.decrease_balance(500) | ||
| print(f'Баланс после снятия средств: {account.balance}') | ||
|
|
||
| try: | ||
| account.decrease_balance(2000) | ||
| except ValueError as e: | ||
| print(f'Ошибка: {e}') | ||
|
|
||
| print(f'Баланс после неудачной попытки снятия средств: {account.balance}') | ||
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.
💡 вообщем то сильно без разницы, я чтобы окружение под ногами не мешалось обычно в
.venvделаю (как и многие тулзы вродеpoetry,pdm) и прочих