-
Notifications
You must be signed in to change notification settings - Fork 0
Moiseev dmitry #69
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?
Moiseev dmitry #69
Changes from all commits
1791dff
8c7b946
c63abad
92b81d6
71db7a3
797129d
1ddcaee
32dfe88
9eeea1e
4fbd336
4be8562
54c0be5
2ff347e
3cc087a
0c177ac
1515497
44a86f6
fbfd5d4
22126d8
bc9a709
0b6924f
37a46b2
4d3f243
306c941
0bb52f0
0472c37
6316397
162b293
0cbee17
7f3c4b3
0240b0d
5f18ada
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,11 @@ | ||
| i = 0 | ||
| while i < 100: | ||
| i += 1 | ||
| if i % 15 == 0: | ||
| print('FizzBizz') | ||
| elif i % 5 == 0: | ||
| print('Bizz') | ||
| elif i % 3 == 0: | ||
| print('Fizz') | ||
| else: | ||
| print(i) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| s = input('Введите пятизначное число: ') | ||
| i = 0 | ||
| while i < len(s): | ||
| i += 1 | ||
| print(f'{i} Цифра равна: {s[i-1]}') |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| str_num = "" | ||
|
|
||
| while True: | ||
| s = input('Введите число, для выхода введите "stop" : ') | ||
|
|
||
| if s.lower() == 'stop': | ||
| break | ||
|
|
||
| if not s.isdecimal(): | ||
| print('--Введите только число--') | ||
| continue | ||
|
|
||
| str_num += s | ||
| print(str_num) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import random | ||
|
|
||
|
|
||
| s = ('Ты сам-то понял, что написал?', 'Аргументируй', 'И?') | ||
|
|
||
| while True: | ||
| question = input('Задайте вопрос: ') | ||
|
|
||
| if question.lower() == 'хватит': | ||
| print('---Выход из программы---') | ||
| break | ||
| else: | ||
| answers = random.choice(s) | ||
| print(answers) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| import random | ||
|
|
||
|
|
||
| s = int(input('Введите нижний диапазон: ')) | ||
| s1 = int(input('Введите верхний диапазон: ')) | ||
| num = random.randint(s, s1) | ||
|
|
||
| while True: | ||
| guess_str = input('Угадайте число: ') | ||
| if not guess_str.isdecimal(): | ||
| print('---Завершение---') | ||
| break | ||
| guess = int(guess_str) | ||
| if guess == num: | ||
| print('---Вы угадали---') | ||
| break | ||
| elif guess < num: | ||
| print(' Ваше число меньше ') | ||
| elif guess > num: | ||
| print(' Ваше число больше ') |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| def max_item(a, b): | ||
| print(max(a, b)) | ||
|
|
||
|
|
||
| def max_ret(a, b): | ||
| return max(a, b) | ||
|
|
||
|
|
||
| high = int(input('Введите первое число: ')) | ||
| low = int(input('Введите второе число: ')) | ||
| max_item(high, low) | ||
| b = max_ret(high, low) | ||
| print(b) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| def decor_start(start): | ||
| def decor_finish(*args, **kwargs): | ||
| print("=====1======") | ||
| res = start(*args, **kwargs) | ||
| print("=====2======") | ||
| return res | ||
| return decor_finish | ||
|
|
||
|
|
||
| @decor_start | ||
| def start_finish(start): | ||
| print(start) | ||
|
|
||
|
|
||
| start_finish('=================') | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| import random | ||
|
|
||
|
|
||
| game_list = ("камень", "ножницы", "бумага") | ||
|
|
||
| while True: | ||
| game = random.choice(game_list) | ||
| s = input('Введите слово "КАМЕНЬ", "НОЖНИЦЫ", или "БУМАГА": ') | ||
| s = s.lower() | ||
| if s == 'камень': | ||
| if game == game_list[0]: | ||
| print(f'---{game}---\n Ничья') | ||
| elif game == game_list[1]: | ||
| print(f'---{game}---\n Вы выиграли') | ||
| else: | ||
| print(f'---{game}---\n Вы проиграли') | ||
|
|
||
| elif s == 'ножницы': | ||
| if game == game_list[0]: | ||
| print(f'---{game}---\n Вы проиграли') | ||
| elif game == game_list[1]: | ||
| print(f'---{game}---\n Ничья') | ||
| else: | ||
| print(f'---{game}---\n Вы выиграли') | ||
|
|
||
| elif s.lower() == 'бумага': | ||
| if game == game_list[0]: | ||
| print(f'---{game}---\n Вы выиграли') | ||
| elif game == game_list[1]: | ||
| print(f'---{game}---\n Вы проиграли') | ||
| else: | ||
| print(f'---{game}---\n Ничья') |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| def current_index(arr, idx): | ||
| idx_min = idx | ||
| i = idx | ||
| # while i < len(arr): | ||
| # if arr[i] < arr[idx_min]: | ||
| # idx_min = i | ||
| # i += 1 | ||
| for i in range(idx, len(arr)): | ||
| if arr[i] < arr[idx_min]: | ||
| idx_min = i | ||
| i += 1 | ||
| return idx_min | ||
|
|
||
|
|
||
| def min_element(elm): | ||
| for i in range(len(elm)): | ||
| cur_idx = current_index(elm, i) | ||
| if cur_idx != i: | ||
| elm[cur_idx], elm[i] = elm[i], elm[cur_idx] | ||
| return elm | ||
|
|
||
|
|
||
| a = [0, 3, 24, 2, 3, 7] | ||
| res = min_element(a) | ||
| print(res) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| class Tank: | ||
| def __init__(self, power, model): | ||
| self.power = power | ||
| self.model = model | ||
|
|
||
| class T34(Tank): | ||
| def shoot(self): | ||
| print(self.model, ' - Бах') | ||
|
|
||
| class Tiger(Tank): | ||
| def shoot(self): | ||
| print(self.model, ' - Ба-бах') | ||
|
|
||
| class Abrams(Tank): | ||
| def shoot(self): | ||
| print(self.model, ' - Ба-ба-бах') | ||
|
|
||
| while True: | ||
| t = input('Введите одну из мощностей выстрела: 30 - 80 - 90 ') | ||
| if t.lower() == 'stop': | ||
| print('Выход из программы') | ||
| break | ||
| elif t == '30': | ||
| tnk1 = T34(30, 'T34') | ||
| tnk1.shoot() | ||
| elif t == '80': | ||
| tnk2 = Tiger(80, 'Tiger') | ||
| tnk2.shoot() | ||
| elif t == '90': | ||
| tnk3 = Abrams(90, 'Abrams') | ||
| tnk3.shoot() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| class Duck: | ||
| def __init__(self, name, weight, collor): | ||
| self._name = name | ||
| self._weight = weight | ||
| self._collor = collor | ||
|
|
||
| def name_weight(self): | ||
| print('Имя:', self._name, ' Вес:', self._weight, 'кг') | ||
|
|
||
| def __repr__(self): | ||
| return f'class Duck: name = {self._name} weight = {self._weight} collor = {self._collor}' | ||
|
|
||
| def __lt__(self, other): | ||
| if self._weight < other._weight: | ||
| return other._name | ||
| else: | ||
| return self._name | ||
|
|
||
| def __ne__(self, other): | ||
| return self._weight != other._weight | ||
|
|
||
| def __add__(self, other): | ||
| return self._weight + other._weight | ||
|
Owner
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. Отступов многовато.
Collaborator
Author
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. исправил
Owner
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. Нет. И в других методах стало так же (8 пробелов, а должно быть 4). Возможно, проблема с табуляцией.
Collaborator
Author
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. исправил
Owner
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. Нет. Ничего не исправилось (см. вкладку Files changed - https://github.com/IlyaOrlov/PythonCourse2.0_August22/pull/69/files) |
||
|
|
||
| @classmethod | ||
| def collor_duck(cls, collor): | ||
| print(cls, collor) | ||
|
|
||
| @staticmethod | ||
| def crack_duck(): | ||
| print('Crack') | ||
|
|
||
|
|
||
| p = Duck('Гага', 4, 'белый',) | ||
| p1 = Duck('КряКря', 7, 'черный',) | ||
|
|
||
| p.crack_duck() | ||
| p.collor_duck('черный') | ||
| p.name_weight() | ||
| print(repr(p)) | ||
| print(repr(p1)) | ||
| print('Самая тяжелая утка: ', p < p1) | ||
| print('Вес уток не равен: ', p != p1) | ||
| print('Общий вес уток: ', p + p1) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| class Man: | ||
| def __init__(self, name): | ||
| self._name = name | ||
|
|
||
| def solve_task(self): | ||
| print("I'm not ready yet") | ||
|
|
||
|
|
||
| res = Man('Дмитрий') | ||
| res.solve_task() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| import time | ||
| import random | ||
|
|
||
|
|
||
| class Pupil: | ||
| def __init__(self, name): | ||
| self._name = name | ||
|
|
||
| def solve_task(self): | ||
| print("I'm not ready yet") | ||
|
|
||
|
|
||
| class Tim(Pupil): | ||
| def solve_task(self): | ||
| n = random.randint(3, 6) | ||
| time.sleep(n) | ||
| super().solve_task() | ||
|
|
||
|
|
||
| res = Tim('Дмитрий') | ||
| res.solve_task() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| class Bank: | ||
| def __init__(self, cash): | ||
| self._cash = cash | ||
|
|
||
|
|
||
| class Bankomat1(Bank): | ||
| def input_output(self): | ||
| while True: | ||
| inp = input('Внести деньги - введите "1". Для снятия - "2" ') | ||
| if inp.lower() == '1': | ||
| inp = int(input('Положите купюры в лоток: ')) | ||
| self._cash += inp | ||
| elif inp.lower() == '2': | ||
| out = int(input('Введите требуемую сумму: ')) | ||
| if self._cash < out: | ||
| print('=== Не достаточно денег в банкомате ===') | ||
| continue | ||
| self._cash -= out | ||
| else: | ||
| print('----- Неправильный ввод.-----\n ' | ||
| 'Для выхода введите: EXIT \n' | ||
| 'Для продолжения операции введите любой знак: ') | ||
| stop = input('---- ') | ||
| if stop.lower() == 'exit': | ||
| print('Выход') | ||
| break | ||
| continue | ||
| print(f'Оставшаяся наличность в Bankomat1 : {self._cash}') | ||
|
|
||
|
|
||
| class Bankomat2(Bank): | ||
| def exchange(self): | ||
| print(f'Оставшаяся наличность в Bankomat2: {self._cash}') | ||
|
|
||
|
|
||
| class Bankomat3(Bank): | ||
| def transfer(self): | ||
| print(f'Оставшаяся наличность в Bankomat3: {self._cash}') | ||
|
|
||
|
|
||
| #lst = Bank(1000) | ||
| lst1 = Bankomat1(500) | ||
| lst2 = Bankomat2(1500) | ||
| lst3 = Bankomat3(3000) | ||
|
|
||
| lst1.input_output() | ||
|
Owner
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. А как узнать, какие операции поддерживает тот или иной банкомат? |
||
| lst2.exchange() | ||
| lst3.transfer() | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import time | ||
|
|
||
|
|
||
| class timeManager: | ||
|
|
||
| def __enter__(self): | ||
| self.t1 = time.time() | ||
| print(f'Запуск таймера в менеджере контекста {self.t1}') | ||
|
|
||
| def __exit__(self, exc_type, exc_val, exc_tb): | ||
| self.t2 = time.time() - self.t1 | ||
| print('Остановка таймера менеджера контекста') | ||
| print(f'Время исполнения кода {self.t2}') | ||
|
|
||
|
|
||
| lst =range(2, 100000) | ||
| with timeManager(): | ||
| for i in lst: | ||
| print(i) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Реализовать итератор, который бы "читал" заданный текст по параграфам. &Символ параграфа задается отдельно. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| Привет! | ||
| Добро пожаловать на Python. | ||
| Удачи в обучении! |
Uh oh!
There was an error while loading. Please reload this page.