# Find the union and intersection of two arrays in Python

Here, we will figure out how to locate the association and convergence of two arrays in Python programming language?

Two arrays will be given by the client and we need to locate the association and crossing point of these arrays in the Python programming.

To locate the association and crossing point of these arrays, we will utilize the bitwise or (|) and bitwise (and) individually between the arrangement of the given arrays.

Before going to take care of this issue we will find out about the association and crossing point.

### Association and convergence of two arrays

A rundown that has the basic particular element from the two arrays and on the off chance that there are redundancies of the element, at that point, just a single event is considered, known as the association of the two arrays.

A rundown that has normal unmistakable elements from the two arrays, is the crossing point of the two arrays.

### The calculation to take care of this issue:

1. At first, we will take two records from the client which may have rehashed numbers or not.
2. We will take the bitwise or (|) between the arrangements of the two arrays to discover association and allocate it into a variable An as records.
3. To discover the crossing point of the two arrays, we will utilize the bitwise (and) between the arrangements of given arrays and allocate it into a variable B as records.
4. Print variable A and B which is our necessary example.

How about we start composing the Python program by the usage of the above calculation.

### Code:

``````a=list(map(int,input('Enter elements of first list:').split()))
b=list(map(int,input('Enter elements of second list:').split()))

A=list(set(a)|set(b))
B=list(set(a)&set(b))

print('Union of the arrays:',A)
print('intersection of the arrays:',B)
``````

### Output:

``````Enter elements of first list: 3 4 6 4  4 6 7 41
Enter elements of second list: 78 3 5 7 -1 9 2 -5
Union of the arrays: [2, 3, 4, 5, 6, 7, 41, 9, 78, -5, -1]
intersection of the arrays: [3, 7]``````

the set() function is inbuilt in Python which is utilized to change over a rundown into another rundown which doesn’t contain a copy or rehashed elements.