1- # class Square:
2- # def __init__(self, side = 2):
3- # self.side = side
4- #
5- # @property
6- # def area(self):
7- # return self.side ** 2
8- #
9- # def __str__(self):
10- # return f"Квадрат со стороной {self.side} имеет площадь {self.area}"
11- #
12- # def __repr__(self):
13- # return f"Значения квадрата:\nside = {self.side}"
14- #
15- # class Rectangle(Square):
16- # def __init__(self, side = 2, length = 5):
17- # super().__init__(side)
18- # self.length = length
19- #
20- # @property
21- # def area(self):
22- # return self.side * self.length
23- #
24- # def __str__(self):
25- # return f"Прямоугольника со стороной от квадрата {self.side} и шириной {self.length} имеет площадь {self.area}"
26- #
27- # def __repr__(self):
28- # return f"Значения прямоугольника:\nside = {self.side} (Наследование от квадрата)\nlength = {self.length}"
29- #
30- #
31- # lysis = Square()
32- # user_lysis = Square(4)
33- #
34- # enigma = Rectangle()
35- # user_enigma = Rectangle(4)
36- #
37- # print("." * 75)
38- # print(user_lysis, repr(lysis), sep="\n")
39- #
40- # # print(user_enigma, repr(enigma), sep="\n")
41- # from PyQt5.QtCore.QUrl import kwargs
42- # from fontTools.misc.cython import returns
43- # from win11toast import result
44- from telethon .crypto .libssl import encrypt_ige
45-
46- # x = {1: "Apple", 2: "Pineapple", 3: "Cherry"}
47- #
48- # try:
49- # # print(x.get(4))
50- # result = 1 / 0
51- # except ZeroDivisionError:
52- # print("Ошибка синтаксиса")
53- # except Exception:
54- # print("Какая-то ошибка")
55-
56- # import random
57- #
58- # from youtube_dl.utils import limit_length
59- #
60- # x = ["Gena", "Nicola", "Egor", "Sasha"]
61- #
62- # def repeat(num_times): # Внешний слой принимает те параметры, которые будут у декоратора.
63- # def decorator(func): # Средний слой получает саму функцию как объект
64- # def wrapper(*args, **kwargs): # Внутренний слой является заменой оригинальной функции
65- # for _ in range(num_times):
66- # result = func(*args, **kwargs)
67- # return result
68- # return wrapper
69- # return decorator
70- #
71- # @repeat(num_times=5)
72- # def choose(name):
73- # print(f"Привет {name}, сегодня на твоём пути будет - {random.choice(x)}")
74-
75- # choose("Misa")
76-
77- x = [9 ,2 ,8 ,4 ,5 ,6 ]
78-
79- # Итератор
80- class Enigma :
81- def __init__ (self , limit ):
82- self .limit = limit
83- self .count = 0
84-
85- def __iter__ (self ):
86- return self
87-
88- def __next__ (self ):
89- if self .count < self .limit :
90- self .count += 1
91- return self .count
92- raise StopIteration
93-
94- # Генератор
95- def rogen (limit ):
96- count = 1
97- while count <= limit :
98- yield count
99- count += 1
100-
101- enigma_test = Enigma (len (x ))
102- for i in enigma_test :
103- print (f"Элемент из списка: { x [i - 1 ]} " )
104-
105- print ("-" * 20 )
106-
107- rogen_test = rogen (len (x ))
108- for i in rogen_test :
109- print (f"Скибоб: { x [i - 1 ]} " )
110-
111- y = list (set (x ))
112- print (y )
1+ from random import randint
2+
3+ a = []
4+ for i in range (10 ):
5+ a .append (randint (1 ,9 ))
6+ print (f'Изначальный: { a } ' )
7+
8+ def bubble_sort (a ):
9+ n = len (a )
10+ for i in range (2 ):
11+ for j in range (n - i - 1 ):
12+ if a [j ] > a [j + 1 ]:
13+ a [j ], a [j + 1 ] = a [j + 1 ], a [j ]
14+ return a
15+
16+ bubble_sort (a )
17+
18+ max_value = ((a [- 1 ]- 1 )* (a [- 2 ]- 1 ))
19+ print (f'Отсортированный: { a } ' )
20+ print (max_value )
0 commit comments