From e8b3d8839b718fd0c510b5d9b82716804ce5e978 Mon Sep 17 00:00:00 2001 From: Filipenko <114gtrap@gmail.com> Date: Tue, 16 May 2023 16:56:40 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B5=D1=88=D0=B5=D0=BD=D1=8B=20=D0=B7?= =?UTF-8?q?=D0=B0=D0=B4=D0=B0=D1=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 main.py diff --git a/main.py b/main.py new file mode 100644 index 0000000..06c8d81 --- /dev/null +++ b/main.py @@ -0,0 +1,55 @@ +def tpl_sort(data: tuple): + lst = list(data) + for el in lst: + if type(el) == str: + return data + return tuple(sorted(data)) + + +def slicer(data: tuple, element) -> tuple: + if element not in data: + return tuple() + listed = list(data) + + start_index = listed.index(element) + res = [listed[start_index]] + start_index += 1 + + while start_index < len(listed): + res.append(listed[start_index]) + if listed[start_index] == element: + break + start_index += 1 + return tuple(res) + + +def sieve(data: list): + return tuple(set(reversed(data))) + + +def deleting_el(data: tuple, element): + if element not in data: + return data + result = list(data) + result.remove(element) + return tuple(result) + + +tpl = (23, 69, 13, 17, 18, 16, 97, 16, 15, 14, 13, 96, 1234, 1, 3, 1, 89) +print(tpl_sort(tpl)) + +print("\n\nTask 2 tests:") +print(slicer(tpl, 13)) +print(slicer(tpl, 1)) +print(slicer(tpl, 89)) +print(slicer(tpl, 89678)) + +# Task 3 test +print("\n\nTask 3 test:") +print(sieve((list(tpl)))) + +# Task 4 tests +print("\n\nTask 4 tests:") +print(deleting_el(tpl, 43567)) +print(deleting_el(tpl, 1)) +print(deleting_el(tpl, 17))