Morse Code Data Python Programming Question

Write a UDT (class) to contain MorseCode data, as stored in the MorseCode.csv file.  Read each line from the MorseCode.csv file and convert it to a MorseCode object.  After constructing the MorseCode object, insert it into a Python List holding MorseCode objects.  The MorseCode list should also be a data member of a UDT class.

Save Time On Research and Writing
Hire a Pro to Write You a 100% Plagiarism-Free Paper.
Get My Paper

Define the necessary operators to support Sorting and Comparing MorseCode objects.  First sort the MorseCode list by Letter or Number.  Then convert this sentence to MorseCode by looking up each character in the list and printing the MorseCode:

“THE QUICK BROWN POODLE JUMPED OVER THE LAZY FOX 123 TIMES”

class Element :
def __init__(self,nu,ab,na) : # constructor
self.number = int(nu)
self.abbrev = ab
self.name = na
def __str__(self): # string conversion operator
return str(self.name + ‘\t’ + self.abbrev + ‘\t’ + str(self.number))
def __lt__(self,right): # less-than operator
return self.number < right.number def __eq__(self,right): return self.number == right.number class PeriodicList : def __init__(self, size): #constructor self.length = size self.table = [ ] def Reader(self,csvfile): csv = open(csvfile) for line in csv : rline = line.rstrip() cline = rline.split(',') self.table.append(Element(int(cline[0]),cline[1],cline[2])) def Output(self) : for i in range(0,len(self.table)): print(self.table[i]) def Sort(self): self.table.sort() def main(): pt = PeriodicList(120) pt.Reader('PeriodicTable.csv') pt.Output() # sorted by name pt.Sort() pt.Output() # sorted by number efind = Element(80,"Hg","Mercury") if efind in pt.table: print("Found " + str(efind)) print("index = ", pt.table.index(efind)) if __name__=="__main__": main() class Water: def __init__(self,s): self.hydrogen = 2 self.oxygen = 1 self.hightemperature = 0 self.lowtemperature = 0 self.state = s def __str__(self): # reused by derived classes return self.state class Solid(Water): def __init__(self): super().__init__("Solid") Water.hightemperature = 0 Water.lowtemperature = -400 # no __str__ class Liquid(Water): def __init__(self): super().__init__("Liquid") Water.hightemperature = 99 Water.lowtemperature = 1 # no __str__ class Gas(Water): def __init__(self): super().__init__("Gas") Water.hightemperature = 1000 Water.lowtemperature = 100 # no __str__ water = Water("Water") print(water) water = Solid() print(water) water = Liquid() print(water) water = Gas() print(water)

Save Time On Research and Writing
Hire a Pro to Write You a 100% Plagiarism-Free Paper.
Get My Paper
Still stressed from student homework?
Get quality assistance from academic writers!

Order your essay today and save 25% with the discount code LAVENDER