#### 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:

E_inter_F.add(x)

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

my-courses.net