sguruapp@gmail.com
facebook vk instagram Одноклассники youtube

Practic = set()


Practic = set()

set1 = {1,3,5,7,9, -2}
set2 = {2,4,6,8,0, -2}

# union
print(set1.union(set2))
# or
print(set1 | set2)
# result {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -2}


# difference
print(set1.difference(set2))
# or
print(set1 - set2)
# result {1, 3, 5, 7, 9}


# intersection
print(set1.intersection(set2))
# or
print(set1 & set2)
# result {-2}


# symmetric_difference
print(set1.symmetric_difference(set2))
# or
print(set1 ^ set2)
# result {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}

Возврат к списку