set operations on python

import math

first_set={1,math.pi,"d"}
second_set={"care","l",4,1,24,2,4,1,2}

first_set.add(12)
second_set.remove(4)

union=first_set | second_set
intersection=first_set & second_set
difference=first_set - second_set
symmetric_difference=first_set ^ second_set

#It showed the contents of clusters without similar elements in the cluster.
print(list(set(second_set)))

print("first set size : ",len(first_set))
print ("\n",union)
print ("\n",intersection)
print ("\n",difference)
print ("\n",symmetric_difference)



from itertools import product,permutations,accumulate

prodct=list(product(first_set,range(1)))
print(prodct,"\n")

perm=list(permutations(first_set))
print(perm)

accumlt=list(accumulate(str(first_set)))
print("accumulate :\n",accumlt)

Comments

Popular posts from this blog

Tech Duos For Web Development

CIFAR-10 Dataset Classification Using Convolutional Neural Networks (CNNs) With PyTorch

Long-short-term-memory (LSTM) Word Prediction With PyTorch