08-02-02 Sets - set addition/removal

Ace your homework & exams now with Quizwiz!

Given that s refers to a set, write a statement that adds the integer value 42 to the set.

s.add(42)

Given that v has been defined, and that s contains a set, write a statement that adds the value of v to set s.

s.add(v)

Given that s refers to a set, write a statement that attempts to remove the integer value 11 from the set, but will do nothing if 11 is not in the set.

s.discard(11)

Given that v has been defined, and that s contains a set, write a statement that attempts to remove the value assigned to v from set s, but will do nothing if it is not in s.

s.discard(v)

Given that s refers to a set, write a statement that removes the integer value 5 from the set.

s.remove(5)

Given that v has been defined, and that s contains a set, write a statement that removes the value of v from the set.

s.remove(v)


Related study sets

Intro to Info Systems (Homework #4)

View Set

Real Estate Investment and Finance 354-446

View Set

Chapter 3: Describing Data: Numerical Measures

View Set