Python is a need to for college kids and running specialists to emerge as a amazing software program Engineer-Python-courses- specially while they-Python-courses-re running in net improvement area. i can list down some of the key-Python-courses- advantages of mastering Python-Python-courses--Python-courses- Python is Interpreted − Python is processed at runtime by using the interpreter. You do no longer need to assemble your application before executing it. this is much like PERL and personal home page. Python is Interactive − you may definitely take a seat at a Python set off and have interaction with the interpreter directly to write down your applications-Python-courses- Python is object-oriented − Python helps item-oriented style or technique of programming-Python-courses- that encapsulates code inside objects-Python-courses- Python is a beginner-Python-courses-s Language − Python is a excellent language for the novice-level programmers-Python-courses- and helps the improvement of a wide variety of packages from simple textual content processing to WWW-Python-courses-

Exercise 204

Write a Python program as function which takes as parameters two sets E and F, such that E included in F and returns the complement of F in E. Example if

E = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'}

and

F = { 'c', 'd', 'e',  'h'}

The function returns:

{'a', 'b', 'f', 'g'}

Solution

def complemntSets(E , F):

# initializing the complment of set F
Complement_F = set({})

for x in E:
if x not in F:
Complement_F.add(x)

return Complement_F

# Testing algorithm
E = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'}
F = { 'c', 'd', 'e', 'h'}
print("Complement_F = " , complemntSets(E , F))
# display: Complement_F = {'f', 'g', 'a', 'b'}

Younes Derfoufi
my-courses.net

Leave a Reply