Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
dc1b77e
4.5
KseniaKatrashova Oct 4, 2022
04b6123
Merge branch 'main' of https://github.com/IlyaOrlov/PythonCourse2.0_A…
KseniaKatrashova Oct 4, 2022
67a7f57
4.5
KseniaKatrashova Oct 4, 2022
9a321f9
4.6
KseniaKatrashova Oct 4, 2022
6af927c
4.8
KseniaKatrashova Oct 5, 2022
aa26a35
Merge branch 'main' of https://github.com/IlyaOrlov/PythonCourse2.0_A…
KseniaKatrashova Oct 7, 2022
7c630ce
4.7
KseniaKatrashova Oct 8, 2022
45092e1
Merge branch 'main' of https://github.com/IlyaOrlov/PythonCourse2.0_A…
KseniaKatrashova Oct 8, 2022
7d53613
Merge branch 'main' of https://github.com/IlyaOrlov/PythonCourse2.0_A…
KseniaKatrashova Oct 9, 2022
1d9d456
5.1
KseniaKatrashova Oct 9, 2022
e3b3eab
5.1 and 5.2
KseniaKatrashova Oct 9, 2022
3e2aa9b
задания по 5 лекции
KseniaKatrashova Oct 12, 2022
97d7437
исправление и задания 6
KseniaKatrashova Oct 13, 2022
f0d8599
Merge branch 'main' of https://github.com/IlyaOrlov/PythonCourse2.0_A…
KseniaKatrashova Oct 13, 2022
ff49008
Merge branch 'main' of https://github.com/IlyaOrlov/PythonCourse2.0_A…
KseniaKatrashova Oct 14, 2022
65c81bc
лекция 7
KseniaKatrashova Oct 15, 2022
0fe3af9
Merge branch 'main' of https://github.com/IlyaOrlov/PythonCourse2.0_A…
KseniaKatrashova Oct 15, 2022
c779204
лекция 8
KseniaKatrashova Oct 18, 2022
b0c13ea
Merge branch 'main' of https://github.com/IlyaOrlov/PythonCourse2.0_A…
KseniaKatrashova Oct 18, 2022
a4d356e
Merge branch 'main' of https://github.com/IlyaOrlov/PythonCourse2.0_A…
KseniaKatrashova Oct 24, 2022
b22793a
Merge branch 'main' of https://github.com/IlyaOrlov/PythonCourse2.0_A…
KseniaKatrashova Oct 28, 2022
dfc5306
func в переменную и возвращаем
KseniaKatrashova Oct 28, 2022
7dc211c
исправлено
KseniaKatrashova Oct 30, 2022
4e491eb
исправлено
KseniaKatrashova Oct 30, 2022
5d191cf
Delete task_5.py
KseniaKatrashova Oct 31, 2022
f7af689
Delete task5.1.py
KseniaKatrashova Oct 31, 2022
63edb1f
Delete Task 03.py
KseniaKatrashova Oct 31, 2022
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
23 changes: 23 additions & 0 deletions Practice/Katrashova/lesson4/les 4.6.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
def find_max(a, b):
if a > b:
return a
elif a < b:
return b
else:
print("Числа равны")
Comment thread
IlyaOrlov marked this conversation as resolved.
x = int(input("Введите число a: "))
y = int(input("Введите число b: "))
res = find_max(x, y)
print(f"Большее число: {res}")


def print_max(a, b):
if a > b:
print(a)
elif a < b:
print(b)
else:
print("Числа равны")
x = int(input("Введите число a: "))
y = int(input("Введите число b: "))
print_max(x, y)
12 changes: 12 additions & 0 deletions Practice/Katrashova/lesson4/les4.7.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
def my_decor(func):
def wrapper():
print("===========")
res = func()
print("===========")
return res
return wrapper

def my_func():
print("Тут основная функция")
my = my_decor(my_func)
my()
26 changes: 26 additions & 0 deletions Practice/Katrashova/lesson4/les4.8.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import random

print("Давай сыграем в камень, ножницы, бумага")
x = ("камень", "ножницы", "бумага")

while True:
y = input("Твой выбор - камень, ножницы, бумага: ")
comp = random.choice(x)
print(f"Вы выбрали {y}, компьютер выбрал {comp}.")
if y == comp:
print("Ничья!")
elif y == "камень":
if comp == "ножницы":
print("Ты победил!")
else:
print("Ты проиграл.")
elif y == "бумага":
if comp == "камень":
print("Ты победил!")
else:
print("Ты проиграл.")
elif y == "ножницы":
if comp == "бумага":
print("Ты победил!")
else:
print("Ты проиграл.")
14 changes: 14 additions & 0 deletions Practice/Katrashova/lesson5/5.1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

def arr_sort(arr):
for i in range(len(arr)):
m = i
for j in range(i + 1, len(arr)):
if arr[j] < arr[m]:
m = j
if i != m:
arr[i], arr[m] = arr[m], arr[i]

array = [0, 3, 24, 2, 3, 7]

arr_sort(array)
print(array)
12 changes: 12 additions & 0 deletions Practice/Katrashova/lesson5/5.2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
def fun(my_list):
new_set = set()
for i in my_list:
if i in new_set:
print(f'Первый повторившийся символ: {my_list[i]} ')
break
else:
new_set.add(my_list[i])


lst = [2, 3, 4, 5, 3, 2]
fun(lst)
7 changes: 7 additions & 0 deletions Practice/Katrashova/lesson5/5.3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
s ="Белеет парус одинокой \nв тумане моря голубом!.."
d = {"Белеет": "one", "парус": "two", "моря": "three"}

print(f"До:\n{s}")
for i, value in d.items():
s = s.replace(i, value)
print(f"После:\n{s}")
27 changes: 27 additions & 0 deletions Practice/Katrashova/lesson5/5.4.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
def search(ls, a):
ind = set()
for i in range(len(ls)):
for m in range(len(ls[i])):
if a == ls[i][m]:
ind.add(m)
ind = list(ind)
return ind


def delete(my_lst, lst_to_remove):
for i in range(len(my_lst)):
for n in reversed(lst_to_remove):
del my_lst[i][n]
return my_lst


lst = [
[1, 2, 3, 4, 5, 6, 7],
[1, 1, 1, 2, 3, 4, 4],
[2, 2, 1, 3, 3, 5, 6]
]

d = int(input("Ведите цифру для удаления стобцов( от 1 до 7): "))
res = search(lst, d)
res2 = delete(lst, res)
print(f"Удалил: {res2}")
10 changes: 10 additions & 0 deletions Practice/Katrashova/lesson5/5.5.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
with open("text.txt", "r") as fo:
reading = fo.read()
my_choice = input("Что заменить? 1 - табуляция на пробелы, 2 - пробелы на табуляцию \n")

with open("text.txt", "w") as fw:
if my_choice == "1":
fw.write(reading.replace("\t", " "))
elif my_choice == "2":
fw.write(reading.replace(" ", "\t"))
print("Файл изменен")
3 changes: 3 additions & 0 deletions Practice/Katrashova/lesson5/text.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
There are different kinds of animals on our planet, and all of them are very important for it.
For example, everybody knows that the sharks are dangerous for people, but they are useful for cleaning seawater.
There are two types of animals: domestic (or pets) and wild.
23 changes: 23 additions & 0 deletions Practice/Katrashova/lesson6/6.1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
class Tank():
def __init__(self, name, crew, weight):
self.name = name
self.crew = crew
self.weight = weight

def show(self):
print(f"Танк {self.name} экипажем {self.crew} человек(а), и массой {self.weight}")

def __lt__(self, other):
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Метод __lt__ должен возвращать True или False, если в задании не указано иное.

if self.weight > other.weight:
print(f'У Игрока {self.name} больше шансов')
elif self.weight == other.weight:
print('Шансы равны')
else:
print(f'У Игрока {self.name} меньше шансов')


player1 = Tank('T-80', 3, 40)
player2 = Tank('T-34', 4, 30)
lst = [player1, player2]
for i in lst:
i.show()
41 changes: 41 additions & 0 deletions Practice/Katrashova/lesson6/6.2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
class Duck:
color = "белый"

def __init__(self, name, weight):
self.name = name
self.weight = weight

@staticmethod
def crack():
print("Сrack")

@classmethod
def color_duck(cls):
print(f"Цвет утки {cls.color}")

def __repr__(self):
return f"Имя утки: {self.name}, вес {self.weight} кг"

def __lt__(self, other):
if self.weight < other.weight:
return f"Утка {other.name} тяжелее"
else:
return f"Утка {self.name} тяжелее"

def __ne__(self, other):
return self.weight != other.weight

def __add__(self, other):
return self.weight + other.weight


duck1 = Duck("Катя", 4)
duck2 = Duck("Вика", 5)

duck1.crack()
duck2.color_duck()
print(duck1)
print(duck2)
print(duck1 < duck2)
print(duck1 != duck2)
print(f"Общий вес уток {duck1 + duck2} кг")
33 changes: 33 additions & 0 deletions Practice/Katrashova/lesson6/6.3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import tempfile
import os


class WrapStrToFile:
def __init__(self):
self._filepath = tempfile.mktemp()

@property
def content(self):
try:
with open(self._filepath, 'r') as f:
return f.read()
except Exception:
return 'Файл еще не существует'

@content.setter
def content(self, value):
with open(self._filepath, 'w') as f:
f.write(value)

@content.deleter
def content(self):
os.remove(self._filepath)


a = WrapStrToFile()
print(a.content) # Output: File doesn't exist
a.content = 'test str'
print(a.content) # Output: test_str
a.content = 'text 2'
print(a.content) # Output: text 2
del a.content # после этого файла не существует
9 changes: 9 additions & 0 deletions Practice/Katrashova/lesson7/les7.1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class Man:
def __init__(self, name):
self.name = name

def solve_task(self):
print("I'm not ready yet")

man = Man('Альберт')
man.solve_task()
21 changes: 21 additions & 0 deletions Practice/Katrashova/lesson7/les7.2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import time
import random

class Man:

def __init__(self, name):
self.name = name
def solve_task(self):
print("I'm not ready yet")

class Pupil(Man):
def solve_task(self):
delay = random.randint(3, 6)
time.sleep(delay)
super().solve_task()


man = Man("Альберт")
pupil = Pupil("Арнольд")
man.solve_task()
pupil.solve_task()
30 changes: 30 additions & 0 deletions Practice/Katrashova/lesson8/8.1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
class Iter:

def __init__(self, text, my_sim):
self.text = text
self.my_sim = my_sim

def __iter__(self):
return self

def __next__(self):
my_str = ' '
new_str = ''
while my_str != '':
my_str = self.text.read(1)
if my_str == self.my_sim:
break
else:
new_str += my_str

if new_str != '':
return new_str
else:
raise StopIteration




with open('text.txt', 'r') as f:
for i in Iter(f, '§'):
print(i)
8 changes: 8 additions & 0 deletions Practice/Katrashova/lesson8/8.2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
def my_gen(file):
with open(file, 'r', encoding='utf8') as f:
for s in f:
yield s


for i in my_gen('text.txt'):
print(i)
17 changes: 17 additions & 0 deletions Practice/Katrashova/lesson8/8.3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import time

class Wait:
def __init__(self):
self.begint = 0

def __enter__(self):
self.begint = time.time()
return self

def __exit__(self, exc_type, exc_val, exc_tb):
print(f"Around time: {time.time() - self.begint} seconds")

with Wait():
arr = []
for i in range(1, 10000000):
arr.append(i**2)
18 changes: 18 additions & 0 deletions Practice/Katrashova/lesson8/8.4.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import itertools


def arr(num1, num2, num3):
joint = list(itertools.chain(num1, num2, num3))
return joint

def less(lst):
filtered = list(itertools.filterfalse(lambda x: len(x) != 5, lst))
return filtered

def key(string, r):
passwords = list(itertools.combinations(string, r))
return passwords

print(arr([1, 2, 3], [4, 5], [6, 7]))
print(less(['hello', 'i', 'write', 'cool', 'code']))
print(key('password', 4))
4 changes: 4 additions & 0 deletions Practice/Katrashova/lesson8/text.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
§ It goes without saying, books are our teachers and friends. They teach us to be kind, clever, polite, hardworking, friendly.
§ Books help us to learn more about nature, the world around us and many other interesting things.There are a lot of books on history, about animals, travellers, children, school and so on.
§ Children like to read adventure and magic books, science fiction and detective stories.
§ They enjoy stories, short stories, novels, fairy-tales, fables and poems.
11 changes: 0 additions & 11 deletions Practice/RybnikovS/Lec 04/Task 03.py

This file was deleted.

Loading