len()
function{}
)setExample1 = {"4061CEM", "Programming", "Algorithms"}
setExample2 = set(["4061CEM", "Programming", "Algorithms"])
setExample1 = {‘Algorithms’, ‘Programming’, ‘4061CEM’}
setExample2 = {‘Algorithms’, ‘Programming’, ‘4061CEM’}
list
, tuple
and
set
data types cannot be hashed or used inside
of a setsetExample1 = {"4061CEM", "Programming", "Algorithms"}
setExample2 = {4061, "Programming and Algorithms", True}
setExample1 = {‘Algorithms’, ‘Programming’, ‘4061CEM’}
setExample2 = {‘Programming and Algorithms’, 4061, True}
for
loopadd()
functionsetExample1 = {‘Algorithms’, ‘Programming’, ‘Dr Ian Cornelius’, ‘4061CEM’}
remove()
function
[Before] setExample1 = {‘Algorithms’, ‘Programming’, ‘4061CEM’}
[After] setExample1 = {‘Algorithms’, ‘4061CEM’}
pop()
function[Before] setExample1 = {‘Algorithms’, ‘Programming’, ‘4061CEM’}
[After] setExample1 = {‘Programming’, ‘4061CEM’}
discard()
function
[Before] setExample1 = {‘Algorithms’, ‘Programming’, ‘4061CEM’}
[After] setExample1 = {‘Algorithms’, ‘4061CEM’}
clear()
function
{}
) or
the set()
constructor[Before] setExample1 = {‘Algorithms’, ‘Programming’, ‘4061CEM’}
[After] setExample1 = set()
del
keywordupdate()
and union()
update()
functionsetExample1 = {"4061CEM", "Programming and Algorithms 1", "Dr Ian Cornelius"}
setExample2 = {"4059CEM", "Legal and Ethical Foundations", "Mr Terry Richards"}
[Before] setExample1 = {‘Programming and Algorithms 1’, ‘4061CEM’, ‘Dr Ian Cornelius’}
[After] setExample1 = {‘Legal and Ethical Foundations’, ‘Dr Ian Cornelius’, ‘Programming and Algorithms 1’, ‘4061CEM’, ‘Mr Terry Richards’, ‘4059CEM’}
union()
function
setExample1 = {"4061CEM", "Programming and Algorithms 1", "Dr Ian Cornelius"}
setExample2 = {"4059CEM", "Legal and Ethical Foundations", "Mr Terry Richards"}
mergedSetExample1 = {‘Legal and Ethical Foundations’, ‘Dr Ian Cornelius’, ‘Programming and Algorithms 1’, ‘4061CEM’, ‘Mr Terry Richards’, ‘4059CEM’}
intersection_update()
function
setExample1 = {"4061CEM", "Programming and Algorithms 1", "Dr Ian Cornelius"}
setExample2 = {"4059CEM", "Legal and Ethical Foundations", "Mr Terry Richards", "Dr Ian Cornelius"}
[Before] setExample1 = {‘Programming and Algorithms 1’, ‘4061CEM’, ‘Dr Ian Cornelius’}
[After] setExample1 = {‘Dr Ian Cornelius’}
intersection()
function
setExample1 = {"4061CEM", "Programming and Algorithms 1", "Dr Ian Cornelius"}
setExample2 = {"4059CEM", "Legal and Ethical Foundations", "Mr Terry Richards", "Dr Ian Cornelius"}
mergedSetExample1 = {‘Dr Ian Cornelius’}
symmetric_difference_update()
function
setExample1 = {"4061CEM", "Programming and Algorithms 1", "Dr Ian Cornelius"}
setExample2 = {"4059CEM", "Legal and Ethical Foundations", "Mr Terry Richards", "Dr Ian Cornelius"}
[Before] setExample1 = {‘Programming and Algorithms 1’, ‘4061CEM’, ‘Dr Ian Cornelius’}
[After] setExample1 = {‘Legal and Ethical Foundations’, ‘Programming and Algorithms 1’, ‘4059CEM’, ‘4061CEM’, ‘Mr Terry Richards’}
symmetric_difference()
function
setExample1 = {"4061CEM", "Programming and Algorithms 1", "Dr Ian Cornelius"}
setExample2 = {"4059CEM", "Legal and Ethical Foundations", "Mr Terry Richards", "Dr Ian Cornelius"}
mergedSetExample1 = {‘Legal and Ethical Foundations’, ‘Programming and Algorithms 1’, ‘4059CEM’, ‘4061CEM’, ‘Mr Terry Richards’}
set2 = set1
is incorrect
set1
and
not an actual copy; therefore, any changes made in
set1
will occur in set2
copy()
function or the set()
constructor itself