### Union and intersection of two arrays

A list that has the common distinct element from both arrays and if there are repetitions of the element then only one occurrence is considered, known as the union of both arrays.

A list that has common distinct elements from both arrays, is the intersection of both arrays.

**Algorithm to solve this problem**

- Initially, we will take two lists from the user which may have repeated numbers or not.
- We will take the
**bitwise or (|)** between the sets of both arrays to find union and assign it into a variable A in the form of lists.
- To find the intersection of both arrays, we will use the
**bitwise and (&)** between the sets of given arrays and assign it into a variable B in the form of lists.
- Print variable A and B which is our required output.

Code:Output

need an explanation for this answer? contact us directly to get an explanation for this answerset() functionis inbuilt in Python which is used to convert a list into another list which does not contain duplicate or repeated elements.