## Sunday, October 11, 2020

Solution Exercise 203: python program that dtermines the union of given sets #### Exercise 203

Write a python program as a function that determines the union of two sets without using any predefined functions. Example if
``E = {"Lenovo", "Hp", "del" , "Accent" , "Asus"}``
and
``F = {"Acer", "Thomson"}``
, the function returns the set:
``{"Lenovo", "Hp", "del" , "Accent" , "Asus" , "Acer", "Thomson"}``

#### Solution

``````def unionSets(E , F):

# initializing the union of sets
E_union_F = set({})
# adding all element of E to the union
for x in E:

# adding all element of F to the union
for x in F:

return E_union_F

# Testing algorithm
E = {"Lenovo", "Hp", "del" , "Accent" , "Asus"}
F = {"Acer", "Thomson"}
print("E_union_F = " , unionSets(E , F))
# display: E_union_F =  {'Lenovo', 'Thomson', 'Acer', 'Hp', 'del', 'Accent', 'Asus'}``````

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 