Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PLEASE ANSWER IN PYTHON!!!!! This is a programming question. Upload the .py file with the answer. Make sure your solution is readable, works, and follows

PLEASE ANSWER IN PYTHON!!!!! image text in transcribed

This is a programming question. Upload the .py file with the answer. Make sure your solution is readable, works, and follows the Python coding style learned in class. Proper indentation is required. Write a class called Set that implements a set object similar to the builtin set class we studied. A Set object is a collection of objects with the semantics of a mathematical set: objects stored in a Set have no duplicates, i.e. adding an object x to a Set should check first if x already exists in the set using the equality operator and should add x to the set only if x did no belong there previously. The order of the elements in a Set is arbitrary. The Set class must have the following "public" methods: constructor, taking a parameter that is a list. The new Set object will contain the elements from the list, excluding duplicates. If the list is empty (I) then a new Set object is created with no elements. _str__(self): returns a string representation of the set that includes all elements' string representation. Set([0,1,2])-_str_() should return "{0,1,2}", with the order of elements being arbitrary. _add__(self, other): implements the union set operation and returns a new Set object with all elements of this (self) object and of the other set, excluding duplicates. __sub__(self, other): implements the set difference operation and returns a new Set object with all elements of this (self) object that do not belong to the other set. __mul_(self, other): implements the set intersection operation and returns a new Set object with all elements of this (self) object that also belong to the other set

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts International Edition

Authors: David M. Kroenke

6th Edition International Edition

0133098222, 978-0133098228

More Books

Students also viewed these Databases questions