-
Notifications
You must be signed in to change notification settings - Fork 0
Lesson_8 #8
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?
Lesson_8 #8
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,38 @@ | ||
| class Data: | ||
| def __init__(self, day_month_year): | ||
| self.day_month_year = str(day_month_year) | ||
|
|
||
| @classmethod | ||
| def extract(cls, day_month_year): | ||
| my_date = [] | ||
|
|
||
| for i in day_month_year.split(): | ||
| if i != '-': my_date.append(i) | ||
|
|
||
| return int(my_date[0]), int(my_date[1]), int(my_date[2]) | ||
|
|
||
| @staticmethod | ||
| def valid(day, month, year): | ||
|
|
||
| if 1 <= day <= 31: | ||
| if 1 <= month <= 12: | ||
| if 2019 >= year >= 0: | ||
| return f'All right' | ||
| else: | ||
| return f'Неправильный год' | ||
| else: | ||
| return f'Неправильный месяц' | ||
| else: | ||
| return f'Неправильный день' | ||
|
|
||
| def __str__(self): | ||
| return f'Текущая дата {Data.extract(self.day_month_year)}' | ||
|
|
||
|
|
||
| today = Data('11 - 1 - 2001') | ||
| print(today) | ||
| print(Data.valid(11, 11, 2022)) | ||
| print(today.valid(11, 13, 2011)) | ||
| print(Data.extract('11 - 11 - 2011')) | ||
| print(today.extract('11 - 11 - 2020')) | ||
| print(Data.valid(1, 11, 2000)) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| class DivisionByNull: | ||
| def __init__(self, divider, denominator): | ||
| self.divider = divider | ||
| self.denominator = denominator | ||
|
|
||
| @staticmethod | ||
| def divide_by_null(divider, denominator): | ||
| try: | ||
| return (divider / denominator) | ||
| except: | ||
| return (f"Деление на ноль недопустимо") | ||
|
|
||
|
|
||
| div = DivisionByNull(10, 100) | ||
| print(DivisionByNull.divide_by_null(10, 0)) | ||
| print(DivisionByNull.divide_by_null(10, 0.1)) | ||
| print(div.divide_by_null(100, 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. не выполнено, в этом задании нужно
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| class Error: | ||
| def __init__(self, *args): | ||
| self.my_list = [] | ||
|
|
||
| def my_input(self): | ||
|
|
||
| # self.my_list = [int(i) for i in input('Введите значения через пробел ').split()] | ||
| # val = int(input('Введите значения и нажимайте Enter - ')) | ||
| # self.my_list.append(val) | ||
| while True: | ||
| try: | ||
| val = int(input('Введите значения и нажимайте Enter - ')) | ||
| self.my_list.append(val) | ||
| print(f'Текущий список - {self.my_list} \n ') | ||
| except: | ||
| print(f"Недопустимое значение") | ||
| y_or_n = input(f'Попробовать еще раз? Y/N ') | ||
|
|
||
| if y_or_n == 'Y' or y_or_n == 'y': | ||
| print(try_except.my_input()) | ||
| elif y_or_n == 'N' or y_or_n == 'n': | ||
| return f'Вы вышли' | ||
| else: | ||
| return f'Вы вышли' | ||
|
|
||
|
|
||
| try_except = Error(1) | ||
| print(try_except.my_input()) | ||
|
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 |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| class StoreMashines: | ||
|
|
||
| def __init__(self, name, price, quantity, number_of_lists, *args): | ||
| self.name = name | ||
| self.price = price | ||
| self.quantity = quantity | ||
| self.numb = number_of_lists | ||
| self.my_store_full = [] | ||
| self.my_store = [] | ||
| self.my_unit = {'Модель устройства': self.name, 'Цена за ед': self.price, 'Количество': self.quantity} | ||
|
|
||
| def __str__(self): | ||
| return f'{self.name} цена {self.price} количество {self.quantity}' | ||
|
|
||
| def reception(self): | ||
| try: | ||
| unit = input(f'Введите наименование ') | ||
| unit_p = int(input(f'Введите цену за ед ')) | ||
| unit_q = int(input(f'Введите количество ')) | ||
| unique = {'Модель устройства': unit, 'Цена за ед': unit_p, 'Количество': unit_q} | ||
| self.my_unit.update(unique) | ||
| self.my_store.append(self.my_unit) | ||
| print(f'Текущий список -\n {self.my_store}') | ||
| except: | ||
| return f'Ошибка ввода данных' | ||
|
|
||
| print(f'Для выхода - Q, продолжение - Enter') | ||
| q = input(f'---> ') | ||
| if q == 'Q' or q == 'q': | ||
| self.my_store_full.append(self.my_store) | ||
| print(f'Весь склад -\n {self.my_store_full}') | ||
| return f'Выход' | ||
| else: | ||
| return StoreMashines.reception(self) | ||
|
|
||
|
|
||
| class Printer(StoreMashines): | ||
| def to_print(self): | ||
| return f'to print smth {self.numb} times' | ||
|
|
||
|
|
||
| class Scanner(StoreMashines): | ||
| def to_scan(self): | ||
| return f'to scan smth {self.numb} times' | ||
|
|
||
|
|
||
| class Copier(StoreMashines): | ||
| def to_copier(self): | ||
| return f'to copier smth {self.numb} times' | ||
|
|
||
|
|
||
| unit_1 = Printer('hp', 2000, 5, 10) | ||
| unit_2 = Scanner('Canon', 1200, 5, 10) | ||
| unit_3 = Copier('Xerox', 1500, 1, 15) | ||
| print(unit_1.reception()) | ||
| print(unit_2.reception()) | ||
| print(unit_3.reception()) | ||
| print(unit_1.to_print()) | ||
| print(unit_3.to_copier()) | ||
|
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 |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| class ComplexNumber: | ||
| def __init__(self, a, b, *args): | ||
| self.a = a | ||
| self.b = b | ||
| self.z = 'a + b * i' | ||
|
|
||
| def __add__(self, other): | ||
| print(f'Сумма z1 и z2 равна') | ||
| return f'z = {self.a + other.a} + {self.b + other.b} * i' | ||
|
|
||
| def __mul__(self, other): | ||
| print(f'Произведение z1 и z2 равно') | ||
| return f'z = {self.a * other.a - (self.b * other.b)} + {self.b * other.a} * i' | ||
|
|
||
| def __str__(self): | ||
| return f'z = {self.a} + {self.b} * i' | ||
|
|
||
|
|
||
| z_1 = ComplexNumber(1, -2) | ||
| z_2 = ComplexNumber(3, 4) | ||
| print(z_1) | ||
| print(z_1 + z_2) | ||
| print(z_1 * z_2) |
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.
выполнено