Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

simple as possible! using CodeLab homework online system that uses python. thank

ID: 3814411 • Letter: S

Question

simple as possible! using CodeLab homework online system that uses python. thank you!

1.

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

2.

Given that v has been defined, and that s that refers to a set, write a statement that adds the value referred to by v to set s.

3.

Given that v has been defined, and that s that refers to a set, write a statement that adds the value referred to by v to set s.

4.

Given that v has been defined, and that s that refers to a set, write a statement that removes the value associated with v from the set.

Explanation / Answer

Please let me know in case of any issue.

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

   .discard(x)
   This operation also removes element from the set.
   If element does not exist, it does not raise a KeyError.
   The .discard(x) operation returns None.

   s.discard(11);

2.
Given that v has been defined, and that s that refers to a set, write a statement that adds the value referred to by v to set s.
       s.add(v);
3.
Given that v has been defined, and that s that refers to a set, write a statement that adds the value referred to by v to set s.
       s.add(v);
4.
Given that v has been defined, and that s that refers to a set, write a statement that removes the value associated with v from the set.

   .remove(x)
   This operation removes element from the set.
   If element does not exist, it raises a KeyError.
   The .remove(x) operation returns None.
  
   s.remove(v)