-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlesson_14.py
30 lines (27 loc) · 1.2 KB
/
lesson_14.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# Containers. list, cortege, set
# Compare texts
def compare_texts():
t1 = """Обратите внимание на порядок элементов результата: /
на первый взгляд он кажется произвольным. Если для /
вас важен порядок элементов, вместо множества лучше/ использовать другой тип данных."""
t2 = """Операция объединения (|) возвращает множество,/
состоящее из всех элементов обоих множеств (с /
исключением дубликатов)"""
t1l = set(t1.split())
t2l = set(t2.split())
words_both = t1l & t2l
words_unic = t1l ^ t2l
print(f"Words in both texts: {words_both}\n")
print(f"Unic words in both texts: {words_unic}\n")
# Find unic methods for list and cortage types
def compare_methods():
li = set(dir([]))
cort = set(dir((1,)))
list_unic = li - cort
cort_unic = cort - li
text = (f"\
This is unic metods for list:\n {list_unic}\n\n\
This is unic methods for cortage:\n {cort_unic}")
print(text)
compare_texts()
compare_methods()