## Saturday, October 10, 2020

Solution Exercise 200: Python algorithm that determines the intersection of two sets #### Exercices 200

Write a program in python as a function that determines the intersection of two sets without using any predefined functions. Example if
``````E = {"Java", "Python", "Javascript", "C ++", "C #"}
#and
F = {"VB.ET", "Java", "Kotlin", "Python"}``````
, the function returns the set:
``{"Java", "Python"}``

#### Solution

``````def set_intersect(E, F):
# initialising the intersection of E and F
E_inter_F = set({})
for x in E:
if x in F:
return E_inter_F

# Testing algorithm
E = {"Java", "Python", "Javascript", "C ++", "C #"}
F = {"VB.ET", "Java", "Kotlin", "Python"}
print("The intersection of E and F is : " , set_intersect(E , F))
# The output is : The intersection of E and F is :  {'Java', 'Python'}``````

Younes Derfoufi
my-courses.net

## Python Exercises With Solutions

1. Python Arithmetic Exercises
2. Equations & System Of Equations
3. Polynomials and Functions
4. Python Arithmetic Exercises
5. Numpy, Matplolib, Sympy , Scipy - Exercises
6. Python Arithmetic Exercises

Younes Derfoufi

## Sample Text 