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

Using python and a While loop to iterate, 1. Write a class called Experience tha

ID: 3710952 • Letter: U

Question

Using python and a While loop to iterate, 1. Write a class called Experience that conforms to the following specifications:

The name of the Experience, followed by a space.

The company of the Experience, followed by a space.

The year of the Experience.


2. Write a class called Resume that conforms to the following specifications:

The name of the Resume, followed by a space

The list of Experiences printed out between [ and ]. Each Experience should be separated by a comma. Don't be surprised if using str() on the list doesn't get you the desired result; you'll need to figure out another way.


3. Complete the load function that takes a list of strings as an argument, and creates a dictionary of strings. The argument of strings contains data that represents Experiences. The keys in the dictionary will be the year of the experience, while the values will be the companies, stored as a list. You may assume that all experiences passed in as arguments never have two experiences with the same company and year. Items will be added to the lists-as-values in the order they are processed in the incoming list argument. The function should return the dictionary. For example, if you had the following function call:
load(["software engineer,IBM,1996", "cashier,Safeway,1983", "architect,Microsoft,1996", "advisor,GMU,1996"])
It would return a dictionary, when printed out, that would look like:
{"1996":["IBM", "Microsoft", "GMU"], "1983":["Safeway"]}


You may find the .split(",") method useful here.

method description constructor Takes a name, company, and year as arguments, and stores them as private attributes. You must give them these variable names. to-string Returns an Experience object in the following format:

The name of the Experience, followed by a space.

The company of the Experience, followed by a space.

The year of the Experience.

Explanation / Answer

class Experience:

def __init__(self, name, company, year):

self.name = name

self.company = company

self.year = year

def to_string(self):

return self.name + " " + self.company + " " + str(self.year)

class Resume:

def __init__(self, name):

self.name = name

self.skills = []

def addExperience(self, experience):

self.skills.append(experience)

def to_string(self):

experience_string = self.name + " ["

experienceList = [ex.to_string() for ex in self.skills]

experienceListString = ','.join(experienceList)

experience_string += experienceListString + " ]"

return experience_string

def load(experienceList):

experienceMap = {}

i = 0

while i < len(experienceList):

experience = experienceList[i]

year = experience.split(',')[2]

company = experience.split(',')[1]

if year not in experienceMap:

experienceMap[year] = []

experienceMap[year].append(company)

i += 1

return experienceMap

def testingClasses():

experience1 = Experience("Software engineer", "IBM", 1996)

experience2 = Experience("Software engineer", "Microsoft", 2000)

experience3 = Experience("Software engineer", "Google", 2009)

print (experience1.to_string())

resume = Resume("John")

resume.addExperience(experience1)

resume.addExperience(experience2)

resume.addExperience(experience2)

print (resume.to_string())

#testingClasses()
print load(["software engineer,IBM,1996", "cashier,Safeway,1983", "architect,Microsoft,1996", "advisor,GMU,1996"])

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote