Set Methods and Function (STSCI 4060)

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/21

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 1:49 PM on 9/15/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

22 Terms

1
New cards

set.clear()

removes all elements from the set, leaving it empty.

2
New cards

set.pop()

removes and returns an arbitrary element from the set.

3
New cards

set.add(item)

inserts a single element into the set.

4
New cards

set.remove(old)

deletes a specific element from the set, raising a KeyError if it's not present.

5
New cards

set.discard()

(same as set.remove()) — deletes a specific element from the set, but does nothing (no error) if it's not present.

6
New cards

set.update(new)

adds all elements from another iterable into the set, in place. (filters out duplicates)

7
New cards

set.intersection_update(new)

keeps only the elements also found in new set in place.

8
New cards

set.difference_update(new)

removes all elements found in another set, in place.

9
New cards

set.symmetric_difference_update(new)

keeps only elements in exactly one of the two sets, in place.

10
New cards

set.copy()

returns a shallow copy of the set.

11
New cards

set.union(new)

returns a new set containing all elements from both sets.

12
New cards

set.intersection(new)

returns a new set of elements common to both sets.

13
New cards

set.symmetric_difference(new)

creates and returns a new set containing all elements that are in either the original set or the new iterable, but not in both.

14
New cards

set.issubset(other)

checks whether every element of the set is also in other

15
New cards

len(set)

returns the number of elements in the set.

16
New cards

max(set)

returns the largest element in the set.

17
New cards

min(set)

returns the smallest element in the set.

18
New cards

sum(set)

returns the sum of all elements in the set (numeric elements only).

19
New cards

any(set)

returns True if at least one element is truthy.

20
New cards

all(set)

returns True if every element is truthy.

21
New cards

sorted(set)

returns a new sorted list of the set's elements.

22
New cards

set.difference(new)

returns a new set of elements in the first set but not the second