From 21b9dbbbdf60ce97b0ded2e0b91e75dcf68be5a3 Mon Sep 17 00:00:00 2001 From: uSeRNameeeeeeeeq Date: Mon, 20 Jul 2020 21:54:00 +0300 Subject: [PATCH 1/9] home --- src/task_5_1.py | 25 +++++++++++++++++++++++++ src/task_5_2.py | 13 +++++++++++++ src/task_5_3.py | 46 ++++++++++++++++++++++++++++++++++++++++++++++ src/task_5_4.py | 6 ++++++ src/task_5_5.py | 18 ++++++++++++++++++ src/task_5_6.py | 8 ++++++++ src/task_5_7.py | 30 ++++++++++++++++++++++++++++++ src/task_5_8.py | 17 +++++++++++++++++ src/task_5_9.py | 30 ++++++++++++++++++++++++++++++ 9 files changed, 193 insertions(+) create mode 100644 src/task_5_1.py create mode 100644 src/task_5_2.py create mode 100644 src/task_5_3.py create mode 100644 src/task_5_4.py create mode 100644 src/task_5_5.py create mode 100644 src/task_5_6.py create mode 100644 src/task_5_7.py create mode 100644 src/task_5_8.py create mode 100644 src/task_5_9.py diff --git a/src/task_5_1.py b/src/task_5_1.py new file mode 100644 index 0000000..8c80acd --- /dev/null +++ b/src/task_5_1.py @@ -0,0 +1,25 @@ + +while True: + + x = int(input()) + y = int(input()) + b = input() + if y == 0: + break + if b == '*' or '/' or '+' or '-': + if b == '*': + z = x * y + print(z) + elif b == '/': + + z = x/y + print(z) + elif b == '+': + z = x + y + print(z) + else: + z = x - y + print(z) +else: + print() + diff --git a/src/task_5_2.py b/src/task_5_2.py new file mode 100644 index 0000000..8715138 --- /dev/null +++ b/src/task_5_2.py @@ -0,0 +1,13 @@ +a = int(input()) +e = 0 +d = 1 +while a > 0: + b = a % 10 + a = a // 10 + d *= b + e += b + + + +print(d) +print(e) \ No newline at end of file diff --git a/src/task_5_3.py b/src/task_5_3.py new file mode 100644 index 0000000..21d19c9 --- /dev/null +++ b/src/task_5_3.py @@ -0,0 +1,46 @@ +e = 0 +c = 0 +d= 0 +a = [] +for chi in range(200, 300): + b = [] + for i in range(1, chi): + if chi % i == 0: + e += i + b.append(e) + e -= i + + i += 1 + a.append(b) + + # print(chi, c) + chi += 1 +h = [] + +for b in a: + d = 0 + for elem in b: + d += elem + h.append(d) + +print(h) + + +sp = [] +for qq in range(200, 300): + sp.append(qq) +print(sp) +sl = dict(zip(sp, h)) +print(sl) + +ez = 0 +for chi in range(200, 300): + for i in range(1, chi): + if chi % i == 0: + ez += i +qw = [] +print(ez) +for ii, u in range(200, 300): + if ez % sl[ii] == 0 and ez % sl[u] == 0 and u != ii and sl[ii] == sl[u]: + qw.append(sl) +print(qw) #Почему-то не запускается, хотя врооде сделал все правильно. diff --git a/src/task_5_4.py b/src/task_5_4.py new file mode 100644 index 0000000..df23771 --- /dev/null +++ b/src/task_5_4.py @@ -0,0 +1,6 @@ +n = int(input()) +s = 0 +while n > 0: + s += (1/n) + n -= 1 +print(s) diff --git a/src/task_5_5.py b/src/task_5_5.py new file mode 100644 index 0000000..e04984d --- /dev/null +++ b/src/task_5_5.py @@ -0,0 +1,18 @@ +import random +e = 0 +j = 0 +for i in range(0, 19): + i = random.randint(0, 100) + if e < i: + e = i + if i % 2 == 0: + i = e + while j < 19: + if j % 2 == 0: + j = e + j += 1 + + print(i) + i += 1 +print(e) + diff --git a/src/task_5_6.py b/src/task_5_6.py new file mode 100644 index 0000000..07c33a0 --- /dev/null +++ b/src/task_5_6.py @@ -0,0 +1,8 @@ +a = [12, 324, 24, 24 ,235, 325, 43, 5,53, 2, 234, 43, 423, 3424, 4] +b = len(a) +i = 0 +c = 0 +for i in range(b -1): + if a[i] = a[i +2]: + c +=1 +print(c) diff --git a/src/task_5_7.py b/src/task_5_7.py new file mode 100644 index 0000000..b9b0cda --- /dev/null +++ b/src/task_5_7.py @@ -0,0 +1,30 @@ + +import random +a=[] +for i in range(1,6): + b = [] + for j in range(1,6): + b.append(random.randint(0,99)) + a.append(b) +print(a) +f = [] +u = 0 +m = b[0] +q = len(b) +for b in a: + for e in range(q): + if u % 5 == 0: + m = 0 + u += 1 + if b[e] > m: + m = b[e] + f.append(m) +print(f) +x = 0 +for b in a: + temp = b[x] + b[x] = f[x] + f[x] = temp + x += 1 +print(a) +print(f) \ No newline at end of file diff --git a/src/task_5_8.py b/src/task_5_8.py new file mode 100644 index 0000000..4648986 --- /dev/null +++ b/src/task_5_8.py @@ -0,0 +1,17 @@ +a = 'rg t r regher ergherh ehth erhe erh' +b = a.split(' ') +c = len(b) +print(b) +i = 0 +while i < len(b): + temp = b[i] + b[i] = b[c-1] + b[c-1] = temp + if i >= (len(b)/2): + break + i += 1 + c -= 1 +print(b) + + + diff --git a/src/task_5_9.py b/src/task_5_9.py new file mode 100644 index 0000000..ae1671c --- /dev/null +++ b/src/task_5_9.py @@ -0,0 +1,30 @@ +# n = int(input()) +# m = int(input()) +# for i in range(2,n): +# if n % i == 0: +# print(f'{n} : {i}') +# i += 1 +# +# for j in range(2,m): +# if m % j == 0: +# print(f'{m} : {j}') +# j += 1 + +n = int(input()) +m = int(input()) +a = [] +for chi in range(n , m + 1): + b = [] + for i in range(2, chi): + if chi % i == 0: + b.append(i) + + + + i += 1 + + + chi += 1 + a.append(b) + a.append(chi) +print(f' :{a}') From b87c2e0a4712b54cbc78eb3bb43b409f0414fc0b Mon Sep 17 00:00:00 2001 From: uSeRNameeeeeeeeq Date: Wed, 22 Jul 2020 15:19:11 +0300 Subject: [PATCH 2/9] HW7: Shalaev Pavel --- src/task_7.py | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 src/task_7.py diff --git a/src/task_7.py b/src/task_7.py new file mode 100644 index 0000000..737a594 --- /dev/null +++ b/src/task_7.py @@ -0,0 +1,86 @@ +def du_cm(a): + c = a * 2.54 + print(c) + return(c) +def cm_du(a): + c = a / 2.54 + print(c) + return(c) +def mi_km(a): + c = a * 1.60934 + print(c) + return(c) +def km_mi(a): + c = a / 1.60934 + print(c) + return(c) +def fu_kg(a): + c = a * 0.453592 + print(c) + return(c) +def kg_fu(a): + c = a / 0.453592 + print(c) + return(c) +def un_g(a): + c = a * 28.3495 + print(c) + return(c) +def g_un(a): + c = a / 28.3495 + print(c) + return(c) +def ga_li(a): + c = a * 0.219969 + print(c) + return(c) +def li_ga(a): + c = a / 0.219969 + print(c) + return(c) +def pi_li(a): + c = a * 0.568261 + print(c) + return(c) +def li_pi(a): + c = a / 0.568261 + print(c) + return(c) +while True: + b = int(input('enter a number in range from 1 to 12 ')) + a = int(input()) + if b == 0: + break + if b == 1: + du_cm(a) + elif b == 2: + cm_du(a) + elif b == 3: + mi_km(a) + elif b == 4: + km_mi(a) + elif b == 5: + fu_kg(a) + elif b == 6: + kg_fu(a) + elif b == 7: + un_g(a) + elif b == 8: + g_un(a) + elif b == 9: + ga_li(a) + elif b == 10: + li_ga(a) + elif b == 11: + li_pi(a) + elif b == 12: + pi_li(a) + + + + + + + + + From baa68092a3cd6a8d09dc1387a163d8b089455d00 Mon Sep 17 00:00:00 2001 From: uSeRNameeeeeeeeq Date: Mon, 17 Aug 2020 20:50:03 +0300 Subject: [PATCH 3/9] hw11 --- src/task_11_1.py | 189 +++++++++++++++++++++++++++++++++++++++++++++++ src/task_11_2.py | 33 +++++++++ 2 files changed, 222 insertions(+) create mode 100644 src/task_11_1.py create mode 100644 src/task_11_2.py diff --git a/src/task_11_1.py b/src/task_11_1.py new file mode 100644 index 0000000..10cd9c1 --- /dev/null +++ b/src/task_11_1.py @@ -0,0 +1,189 @@ +""" +Создать пять классов описывающие реальные объекты. +Каждый класс должен содержать минимум три приватных атрибута, +конструктор, геттеры и сеттеры для каждого атрибута, два метода +""" + +class Tv: + def show(self): + print("shows tv Shows") + + def sound(self): + print("makes sounds") + + def __init__(self, quality, price, size): + self.__quality = quality + self.__price = price + self.__size = size + + @property + def x(self): + return self.__quality + + @x.setter + def quality(self, quality): + self.__quality = quality + + @property + def price(self): + return self.__price + + @price.setter + def price(self, price): + self.__price = price + + @property + def size(self): + return self.__size + + @size.setter + def size(self, size): + self.__size = size + + +class Languages: + def speak(self): + print("word") + + def read(self): + print("text") + + def __init__(self, sounds, letters, phrase): + self.__sounds = sounds + self.__letters = letters + self.__phrase = phrase + + @property + def y(self): + return self.__sounds + + @y.setter + def sounds(self, sounds): + self.__sounds = sounds + + @property + def letters(self): + return self.__letters + + @letters.setter + def price(self, letters): + self.__letters = letters + + @property + def phrase(self): + return self.__phrase + + @phrase.setter + def phrase(self, phrase): + self.__phrase = phrase + + +class Cars: + def drive(self): + print("*driving*") + + def drift(self): + print("*drifting*") + + def __init__(self, colour, appereance, speed): + self.__appereance = appereance + self.__colour = colour + self.__speed = speed + + @property + def fun(self): + return self.__colour + + @fun.setter + def colour(self, colour): + self.__colour = colour + + @property + def look(self): + return self.__appereance + + @look.setter + def price(self, appereance): + self.__appereance = appereance + + @property + def speed(self): + return self.__speed + + @speed.setter + def speed(self, speed): + self.__speed = speed + + +class Human: + def live(self): + print("you r alive") + + def death(self): + print("you r dead") + + def __init__(self, man, woman, kid): + self.__man = man + self.__woman = woman + self.__kid = kid + + @property + def man(self): + return self.__man + + @man.setter + def man(self, man): + self.__man = man + + @property + def woman(self): + return self.__woman + + @woman.setter + def woman(self, woman): + self.__woman = woman + + @property + def kid(self): + return self.__kid + + @kid.setter + def kid(self, kid): + self.__kid = kid + + +class Plant: + def grow(self): + print("plant grows") + + def give(self): + print("plant gives seeds") + + def __init__(self, tree, grass, bush): + self.__tree = tree + self.__grass = grass + self.__bush = bush + + @property + def tree(self): + return self.__tree + + @tree.setter + def quality(self, tree): + self.__tree = tree + + @property + def grass(self): + return self.__grass + + @grass.setter + def price(self, grass): + self.__grass = grass + + @property + def bush(self): + return self.__bush + + @bush.setter + def size(self, bush): + self.__bush = bush diff --git a/src/task_11_2.py b/src/task_11_2.py new file mode 100644 index 0000000..71fcfea --- /dev/null +++ b/src/task_11_2.py @@ -0,0 +1,33 @@ +""" +Создать класс Car. Атрибуты: марка, модель, год выпуска, скорость(по умолчанию 0). +Методы: увеличить скорости(скорость + 5), уменьшение скорости(скорость - 5), +стоп(сброс скорости на 0), отображение скорости, разворот(изменение знака скорости). +Все атрибуты приватные. +""" + +class Car: + def __init__(self, mark, model, year, speed): + self.__mark = mark + self.__model = model + self.__year = year + self.__speed = speed + + def increase(self): + self.__speed += 5 + + def decrease(self): + self.__speed -= 5 + + def set_zero(self): + self.__speed = 0 + + def show(self): + print(self.__speed) + + def minus(self): + self.__speed *= -1 + + +tayota = Car("x4", "new", "2021", 0) +tayota.show() + From 43bc74c9c0ffeee92881547fbe2b012ad3ebf2b5 Mon Sep 17 00:00:00 2001 From: uSeRNameeeeeeeeq Date: Sun, 23 Aug 2020 12:02:57 +0300 Subject: [PATCH 4/9] HW13: Shalaev Pavel --- src/main.py | 23 ++++ src/matrix_utils/__init__.py | 0 src/matrix_utils/matrix_classes.py | 28 +++++ src/matrix_utils/matrix_funcs.py | 19 +++ src/task_11_1.py | 189 ----------------------------- src/task_11_2.py | 33 ----- src/task_5_1.py | 25 ---- src/task_5_2.py | 13 -- src/task_5_3.py | 46 ------- src/task_5_4.py | 6 - src/task_5_5.py | 18 --- src/task_5_6.py | 8 -- src/task_5_7.py | 30 ----- src/task_5_8.py | 17 --- src/task_5_9.py | 30 ----- src/task_7.py | 86 ------------- 16 files changed, 70 insertions(+), 501 deletions(-) create mode 100644 src/main.py create mode 100644 src/matrix_utils/__init__.py create mode 100644 src/matrix_utils/matrix_classes.py create mode 100644 src/matrix_utils/matrix_funcs.py delete mode 100644 src/task_11_1.py delete mode 100644 src/task_11_2.py delete mode 100644 src/task_5_1.py delete mode 100644 src/task_5_2.py delete mode 100644 src/task_5_3.py delete mode 100644 src/task_5_4.py delete mode 100644 src/task_5_5.py delete mode 100644 src/task_5_6.py delete mode 100644 src/task_5_7.py delete mode 100644 src/task_5_8.py delete mode 100644 src/task_5_9.py delete mode 100644 src/task_7.py diff --git a/src/main.py b/src/main.py new file mode 100644 index 0000000..f28b09f --- /dev/null +++ b/src/main.py @@ -0,0 +1,23 @@ +""" +Создать класс Matrix. +Атрибуты - data(содержит саму матрицу - список списков), n, m. +Определить конструктор(с параметрами(передача размерности: n, m и диапазона случайных чисел: a, b), по-умолчанию (матрица 5 на 5 где все элементы равны нулю), копирования) , +переопределить магический метод str для красивого вывода. +Описать функции, которые принимают на вход объект класса Matrix. Функции позволяют искать максимальный элемент матрицы, минимальный, сумму всех элементов. +Создать в файле main.py матрицу. Воспользоваться всеми описанными функциями и методам +""" + + +from matrix_utils.matrix_classes import Matrix +from matrix_utils import matrix_funcs +from matrix_utils import matrix_classes + + +if __name__ == "__main__": + matrix = Matrix(5, 5, 11, 33) + matrix.gen_default_matrix() + print(matrix) + print(matrix_funcs.find_max_matrix_element(matrix)) + print(matrix_funcs.find_min_matrix_element(matrix)) + print(matrix_funcs.find_sum_matrix_elements(matrix)) + diff --git a/src/matrix_utils/__init__.py b/src/matrix_utils/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/matrix_utils/matrix_classes.py b/src/matrix_utils/matrix_classes.py new file mode 100644 index 0000000..d185cdf --- /dev/null +++ b/src/matrix_utils/matrix_classes.py @@ -0,0 +1,28 @@ +from random import randint + + +class Matrix: + def __init__(self, n: int, m: int, a: int, b: int) -> None: + self.n = n + self.m = m + self.a = a + self.b = b + self._data: list[list] = None + + @property + def data(self): + pass + + @data.setter + def data(self, data): + self._data = data + + def gen_default_matrix(self) -> None: + """Сгенерировать матрицу по умолчанию (нулевую)""" + self._data = [ + [randint(self.a, self.b) for _ in range(self.n)] for _ in range(self.m) + ] + return self._data + + def __str__(self) -> str: + return f"your matrix is {self._data}" \ No newline at end of file diff --git a/src/matrix_utils/matrix_funcs.py b/src/matrix_utils/matrix_funcs.py new file mode 100644 index 0000000..73f4031 --- /dev/null +++ b/src/matrix_utils/matrix_funcs.py @@ -0,0 +1,19 @@ +from matrix_utils.matrix_classes import Matrix + + +def find_max_matrix_element(matrix: Matrix) -> int or float: + return max(map(max, matrix._data)) + + +def find_min_matrix_element(matrix: Matrix) -> int or float: + return min(map(min, matrix._data)) + + +def find_sum_matrix_elements(matrix: Matrix) -> int or float: + result = 0 + for elem in matrix._data: + for number in elem: + result += number + return result + + diff --git a/src/task_11_1.py b/src/task_11_1.py deleted file mode 100644 index 10cd9c1..0000000 --- a/src/task_11_1.py +++ /dev/null @@ -1,189 +0,0 @@ -""" -Создать пять классов описывающие реальные объекты. -Каждый класс должен содержать минимум три приватных атрибута, -конструктор, геттеры и сеттеры для каждого атрибута, два метода -""" - -class Tv: - def show(self): - print("shows tv Shows") - - def sound(self): - print("makes sounds") - - def __init__(self, quality, price, size): - self.__quality = quality - self.__price = price - self.__size = size - - @property - def x(self): - return self.__quality - - @x.setter - def quality(self, quality): - self.__quality = quality - - @property - def price(self): - return self.__price - - @price.setter - def price(self, price): - self.__price = price - - @property - def size(self): - return self.__size - - @size.setter - def size(self, size): - self.__size = size - - -class Languages: - def speak(self): - print("word") - - def read(self): - print("text") - - def __init__(self, sounds, letters, phrase): - self.__sounds = sounds - self.__letters = letters - self.__phrase = phrase - - @property - def y(self): - return self.__sounds - - @y.setter - def sounds(self, sounds): - self.__sounds = sounds - - @property - def letters(self): - return self.__letters - - @letters.setter - def price(self, letters): - self.__letters = letters - - @property - def phrase(self): - return self.__phrase - - @phrase.setter - def phrase(self, phrase): - self.__phrase = phrase - - -class Cars: - def drive(self): - print("*driving*") - - def drift(self): - print("*drifting*") - - def __init__(self, colour, appereance, speed): - self.__appereance = appereance - self.__colour = colour - self.__speed = speed - - @property - def fun(self): - return self.__colour - - @fun.setter - def colour(self, colour): - self.__colour = colour - - @property - def look(self): - return self.__appereance - - @look.setter - def price(self, appereance): - self.__appereance = appereance - - @property - def speed(self): - return self.__speed - - @speed.setter - def speed(self, speed): - self.__speed = speed - - -class Human: - def live(self): - print("you r alive") - - def death(self): - print("you r dead") - - def __init__(self, man, woman, kid): - self.__man = man - self.__woman = woman - self.__kid = kid - - @property - def man(self): - return self.__man - - @man.setter - def man(self, man): - self.__man = man - - @property - def woman(self): - return self.__woman - - @woman.setter - def woman(self, woman): - self.__woman = woman - - @property - def kid(self): - return self.__kid - - @kid.setter - def kid(self, kid): - self.__kid = kid - - -class Plant: - def grow(self): - print("plant grows") - - def give(self): - print("plant gives seeds") - - def __init__(self, tree, grass, bush): - self.__tree = tree - self.__grass = grass - self.__bush = bush - - @property - def tree(self): - return self.__tree - - @tree.setter - def quality(self, tree): - self.__tree = tree - - @property - def grass(self): - return self.__grass - - @grass.setter - def price(self, grass): - self.__grass = grass - - @property - def bush(self): - return self.__bush - - @bush.setter - def size(self, bush): - self.__bush = bush diff --git a/src/task_11_2.py b/src/task_11_2.py deleted file mode 100644 index 71fcfea..0000000 --- a/src/task_11_2.py +++ /dev/null @@ -1,33 +0,0 @@ -""" -Создать класс Car. Атрибуты: марка, модель, год выпуска, скорость(по умолчанию 0). -Методы: увеличить скорости(скорость + 5), уменьшение скорости(скорость - 5), -стоп(сброс скорости на 0), отображение скорости, разворот(изменение знака скорости). -Все атрибуты приватные. -""" - -class Car: - def __init__(self, mark, model, year, speed): - self.__mark = mark - self.__model = model - self.__year = year - self.__speed = speed - - def increase(self): - self.__speed += 5 - - def decrease(self): - self.__speed -= 5 - - def set_zero(self): - self.__speed = 0 - - def show(self): - print(self.__speed) - - def minus(self): - self.__speed *= -1 - - -tayota = Car("x4", "new", "2021", 0) -tayota.show() - diff --git a/src/task_5_1.py b/src/task_5_1.py deleted file mode 100644 index 8c80acd..0000000 --- a/src/task_5_1.py +++ /dev/null @@ -1,25 +0,0 @@ - -while True: - - x = int(input()) - y = int(input()) - b = input() - if y == 0: - break - if b == '*' or '/' or '+' or '-': - if b == '*': - z = x * y - print(z) - elif b == '/': - - z = x/y - print(z) - elif b == '+': - z = x + y - print(z) - else: - z = x - y - print(z) -else: - print() - diff --git a/src/task_5_2.py b/src/task_5_2.py deleted file mode 100644 index 8715138..0000000 --- a/src/task_5_2.py +++ /dev/null @@ -1,13 +0,0 @@ -a = int(input()) -e = 0 -d = 1 -while a > 0: - b = a % 10 - a = a // 10 - d *= b - e += b - - - -print(d) -print(e) \ No newline at end of file diff --git a/src/task_5_3.py b/src/task_5_3.py deleted file mode 100644 index 21d19c9..0000000 --- a/src/task_5_3.py +++ /dev/null @@ -1,46 +0,0 @@ -e = 0 -c = 0 -d= 0 -a = [] -for chi in range(200, 300): - b = [] - for i in range(1, chi): - if chi % i == 0: - e += i - b.append(e) - e -= i - - i += 1 - a.append(b) - - # print(chi, c) - chi += 1 -h = [] - -for b in a: - d = 0 - for elem in b: - d += elem - h.append(d) - -print(h) - - -sp = [] -for qq in range(200, 300): - sp.append(qq) -print(sp) -sl = dict(zip(sp, h)) -print(sl) - -ez = 0 -for chi in range(200, 300): - for i in range(1, chi): - if chi % i == 0: - ez += i -qw = [] -print(ez) -for ii, u in range(200, 300): - if ez % sl[ii] == 0 and ez % sl[u] == 0 and u != ii and sl[ii] == sl[u]: - qw.append(sl) -print(qw) #Почему-то не запускается, хотя врооде сделал все правильно. diff --git a/src/task_5_4.py b/src/task_5_4.py deleted file mode 100644 index df23771..0000000 --- a/src/task_5_4.py +++ /dev/null @@ -1,6 +0,0 @@ -n = int(input()) -s = 0 -while n > 0: - s += (1/n) - n -= 1 -print(s) diff --git a/src/task_5_5.py b/src/task_5_5.py deleted file mode 100644 index e04984d..0000000 --- a/src/task_5_5.py +++ /dev/null @@ -1,18 +0,0 @@ -import random -e = 0 -j = 0 -for i in range(0, 19): - i = random.randint(0, 100) - if e < i: - e = i - if i % 2 == 0: - i = e - while j < 19: - if j % 2 == 0: - j = e - j += 1 - - print(i) - i += 1 -print(e) - diff --git a/src/task_5_6.py b/src/task_5_6.py deleted file mode 100644 index 07c33a0..0000000 --- a/src/task_5_6.py +++ /dev/null @@ -1,8 +0,0 @@ -a = [12, 324, 24, 24 ,235, 325, 43, 5,53, 2, 234, 43, 423, 3424, 4] -b = len(a) -i = 0 -c = 0 -for i in range(b -1): - if a[i] = a[i +2]: - c +=1 -print(c) diff --git a/src/task_5_7.py b/src/task_5_7.py deleted file mode 100644 index b9b0cda..0000000 --- a/src/task_5_7.py +++ /dev/null @@ -1,30 +0,0 @@ - -import random -a=[] -for i in range(1,6): - b = [] - for j in range(1,6): - b.append(random.randint(0,99)) - a.append(b) -print(a) -f = [] -u = 0 -m = b[0] -q = len(b) -for b in a: - for e in range(q): - if u % 5 == 0: - m = 0 - u += 1 - if b[e] > m: - m = b[e] - f.append(m) -print(f) -x = 0 -for b in a: - temp = b[x] - b[x] = f[x] - f[x] = temp - x += 1 -print(a) -print(f) \ No newline at end of file diff --git a/src/task_5_8.py b/src/task_5_8.py deleted file mode 100644 index 4648986..0000000 --- a/src/task_5_8.py +++ /dev/null @@ -1,17 +0,0 @@ -a = 'rg t r regher ergherh ehth erhe erh' -b = a.split(' ') -c = len(b) -print(b) -i = 0 -while i < len(b): - temp = b[i] - b[i] = b[c-1] - b[c-1] = temp - if i >= (len(b)/2): - break - i += 1 - c -= 1 -print(b) - - - diff --git a/src/task_5_9.py b/src/task_5_9.py deleted file mode 100644 index ae1671c..0000000 --- a/src/task_5_9.py +++ /dev/null @@ -1,30 +0,0 @@ -# n = int(input()) -# m = int(input()) -# for i in range(2,n): -# if n % i == 0: -# print(f'{n} : {i}') -# i += 1 -# -# for j in range(2,m): -# if m % j == 0: -# print(f'{m} : {j}') -# j += 1 - -n = int(input()) -m = int(input()) -a = [] -for chi in range(n , m + 1): - b = [] - for i in range(2, chi): - if chi % i == 0: - b.append(i) - - - - i += 1 - - - chi += 1 - a.append(b) - a.append(chi) -print(f' :{a}') diff --git a/src/task_7.py b/src/task_7.py deleted file mode 100644 index 737a594..0000000 --- a/src/task_7.py +++ /dev/null @@ -1,86 +0,0 @@ -def du_cm(a): - c = a * 2.54 - print(c) - return(c) -def cm_du(a): - c = a / 2.54 - print(c) - return(c) -def mi_km(a): - c = a * 1.60934 - print(c) - return(c) -def km_mi(a): - c = a / 1.60934 - print(c) - return(c) -def fu_kg(a): - c = a * 0.453592 - print(c) - return(c) -def kg_fu(a): - c = a / 0.453592 - print(c) - return(c) -def un_g(a): - c = a * 28.3495 - print(c) - return(c) -def g_un(a): - c = a / 28.3495 - print(c) - return(c) -def ga_li(a): - c = a * 0.219969 - print(c) - return(c) -def li_ga(a): - c = a / 0.219969 - print(c) - return(c) -def pi_li(a): - c = a * 0.568261 - print(c) - return(c) -def li_pi(a): - c = a / 0.568261 - print(c) - return(c) -while True: - b = int(input('enter a number in range from 1 to 12 ')) - a = int(input()) - if b == 0: - break - if b == 1: - du_cm(a) - elif b == 2: - cm_du(a) - elif b == 3: - mi_km(a) - elif b == 4: - km_mi(a) - elif b == 5: - fu_kg(a) - elif b == 6: - kg_fu(a) - elif b == 7: - un_g(a) - elif b == 8: - g_un(a) - elif b == 9: - ga_li(a) - elif b == 10: - li_ga(a) - elif b == 11: - li_pi(a) - elif b == 12: - pi_li(a) - - - - - - - - - From 2f139c01be5236936bd03e6f91da75cb389526a2 Mon Sep 17 00:00:00 2001 From: uSeRNameeeeeeeeq Date: Sun, 23 Aug 2020 12:18:08 +0300 Subject: [PATCH 5/9] fixed mistakes --- src/main.py | 15 ++++++++++----- src/matrix_utils/matrix_classes.py | 6 +++--- src/matrix_utils/matrix_funcs.py | 2 -- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/main.py b/src/main.py index f28b09f..d600ce5 100644 --- a/src/main.py +++ b/src/main.py @@ -1,16 +1,22 @@ """ Создать класс Matrix. Атрибуты - data(содержит саму матрицу - список списков), n, m. -Определить конструктор(с параметрами(передача размерности: n, m и диапазона случайных чисел: a, b), по-умолчанию (матрица 5 на 5 где все элементы равны нулю), копирования) , +Определить конструктор(с параметрами(передача размерности: n, m +и диапазона случайных чисел: a, b), по-умолчанию +(матрица 5 на 5 где все элементы равны нулю), копирования) , переопределить магический метод str для красивого вывода. -Описать функции, которые принимают на вход объект класса Matrix. Функции позволяют искать максимальный элемент матрицы, минимальный, сумму всех элементов. -Создать в файле main.py матрицу. Воспользоваться всеми описанными функциями и методам +Описать функции, которые принимают на вход объект класса Matrix. + Функции позволяют искать максимальный элемент матрицы, минимальный, + сумму всех элементов. +Создать в файле main.py матрицу. +Воспользоваться всеми описанными функциями и методам """ from matrix_utils.matrix_classes import Matrix -from matrix_utils import matrix_funcs from matrix_utils import matrix_classes +from matrix_utils import matrix_funcs + if __name__ == "__main__": @@ -20,4 +26,3 @@ print(matrix_funcs.find_max_matrix_element(matrix)) print(matrix_funcs.find_min_matrix_element(matrix)) print(matrix_funcs.find_sum_matrix_elements(matrix)) - diff --git a/src/matrix_utils/matrix_classes.py b/src/matrix_utils/matrix_classes.py index d185cdf..2703012 100644 --- a/src/matrix_utils/matrix_classes.py +++ b/src/matrix_utils/matrix_classes.py @@ -20,9 +20,9 @@ def data(self, data): def gen_default_matrix(self) -> None: """Сгенерировать матрицу по умолчанию (нулевую)""" self._data = [ - [randint(self.a, self.b) for _ in range(self.n)] for _ in range(self.m) - ] + [randint(self.a, self.b) for _ in range(self.n)] + for _ in range(self.m)] return self._data def __str__(self) -> str: - return f"your matrix is {self._data}" \ No newline at end of file + return f"your matrix is {self._data}" diff --git a/src/matrix_utils/matrix_funcs.py b/src/matrix_utils/matrix_funcs.py index 73f4031..d6bc963 100644 --- a/src/matrix_utils/matrix_funcs.py +++ b/src/matrix_utils/matrix_funcs.py @@ -15,5 +15,3 @@ def find_sum_matrix_elements(matrix: Matrix) -> int or float: for number in elem: result += number return result - - From 3a3e89a712ba5e7d9335979b88ea847f3c5e3008 Mon Sep 17 00:00:00 2001 From: uSeRNameeeeeeeeq Date: Sun, 23 Aug 2020 12:29:12 +0300 Subject: [PATCH 6/9] fixed.2 --- src/main.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main.py b/src/main.py index d600ce5..418e523 100644 --- a/src/main.py +++ b/src/main.py @@ -13,10 +13,9 @@ """ -from matrix_utils.matrix_classes import Matrix from matrix_utils import matrix_classes from matrix_utils import matrix_funcs - +from matrix_utils.matrix_classes import Matrix if __name__ == "__main__": From da44a8b8c936cb8cabd1f810c58eb2ec3e1ddc51 Mon Sep 17 00:00:00 2001 From: uSeRNameeeeeeeeq Date: Sun, 23 Aug 2020 12:44:16 +0300 Subject: [PATCH 7/9] fixed again --- src/main.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main.py b/src/main.py index 418e523..e392e70 100644 --- a/src/main.py +++ b/src/main.py @@ -13,7 +13,6 @@ """ -from matrix_utils import matrix_classes from matrix_utils import matrix_funcs from matrix_utils.matrix_classes import Matrix From 26ac9385544e1167fe41d9dd713ff59fa43359f2 Mon Sep 17 00:00:00 2001 From: uSeRNameeeeeeeeq Date: Sun, 23 Aug 2020 12:47:26 +0300 Subject: [PATCH 8/9] 4 --- src/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.py b/src/main.py index e392e70..b66b639 100644 --- a/src/main.py +++ b/src/main.py @@ -13,8 +13,8 @@ """ -from matrix_utils import matrix_funcs from matrix_utils.matrix_classes import Matrix +from matrix_utils import matrix_funcs if __name__ == "__main__": From 3dc1db5521455e5626302bf316cbc8468c66116a Mon Sep 17 00:00:00 2001 From: uSeRNameeeeeeeeq Date: Sun, 6 Sep 2020 15:56:21 +0300 Subject: [PATCH 9/9] last commit --- src/matrix_utils/matrix_classes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/matrix_utils/matrix_classes.py b/src/matrix_utils/matrix_classes.py index 2703012..51dc4de 100644 --- a/src/matrix_utils/matrix_classes.py +++ b/src/matrix_utils/matrix_classes.py @@ -17,7 +17,7 @@ def data(self): def data(self, data): self._data = data - def gen_default_matrix(self) -> None: + def gen_default_matrix(self): """Сгенерировать матрицу по умолчанию (нулевую)""" self._data = [ [randint(self.a, self.b) for _ in range(self.n)]