Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Stuck on line 153 as the picture shows SyntaxError: invalid syntax. Not sure what I need to do to fix this? Here is my code:

image text in transcribed

Stuck on line 153 as the picture shows SyntaxError: invalid syntax. Not sure what I need to do to fix this?

Here is my code:

class Employee:

# Implementation of init

def __init__(self, name, ID_number, dept, job_title):

self._name = name

self._ID_number = ID_number

self._department = dept

self._job_title = job_title

# Implementation of setters and getters def set_name(self,name):

self._name=name

def set_dept(self, dept): self._dept=dept

def set_job(self,job): self._job=job

def get_name(self): return self._name

def get_ID_number(self): return self._ID

def get_dept(self): return self._dept

def get_dept(self): return self._dept

def get_job(self): return self._job

def _str_(self): return 'Name:' + self._name+ ' '+\ 'ID Number:' + str(self._ID) + ' '+\ 'dept:' + self._dept + ' ' \ 'Job Title:' + self._job

# import packages import menu_choices import save_load_dict

# menu constants LOOK_UP = 1 ADD = 2 CHANGE = 3 DELETE = 4 QUIT = 5

# Implementation of main function def main(): employees = save_load_dict.unpickle_it()

# Prompt and read choice from user choice = menu_choices.get_menu_choice()

# loop to call functions while choice!= QUIT: if choice == LOOK_UP: menu_choices.look_up(employees)

elif choice == ADD: menu_choices.add(employees)

elif choice == CHANGE: menu_choices.change(employees)

elif choice == DELETE: menu_choices.delete(employees)

choice= menu_choices.get_menu_choice()

save_load_dict.unpickle_it(employees)

main()

# menu_choices.py import employee_class

# Global constants for menu choices LOOK_UP= 1 ADD= 2 CHANGE= 3 DELETE= 4 QUIT= 5

# implementation of get_menu_choice() def get_menu_choice(): print(' Menu ') print('1. Look up an employee') print('2. Add a new employee') print('3. Change the details of an employee') print('4. Delete an employee') print('5. Quit program ')

# Prompt and read choice from user ch= int(input('Enter your choice(1-5):'))

# Check the choice in given range while ch QUIT: ch= int(input('Enter a valid choice(1-5):')) return ch # implementation of look up function def look_up(employees):

# Prompt and read name from user ID= input('Enter an employee ID number:')

# Check dictionary if ID in employees: print(employees[ID]) else: print('That ID number is not found.')

# Implementation of add function def add(employees):

# Prompt and read the employee details from the user name = input('Enter the employee\'s name:') ID = input('Enter the employee\'s ID number:') department = input('Enter the employee\'s department:') job_title = input('Enter the employee\'s job title:') if ID not in employees: employees[ID] = employee_class.Employee(name, ID, department, \ job_title) else: print('Employee ID number already exists.') # Implementation of change function def change(employees):

# Prompt and read the ID from user ID = input('Enter an employee ID number:') if ID in employees:

# Prompt and read employee details from user name = input('Enter the employee\'s name:') department = input('Enter the employee\'s department:') job_title = input('Enter the employee\'s job title:')

# Update the entry employees[ID].set_name(name) employees[ID].set_departmenet(department) employees[ID].set_job_title(job_title)

else: print('ID number was not found.')

# Implementation of delete function def delete(employees):

# Prompt and read ID from the user ID = input('Enter an employee ID number:') if ID in employees: del employees[ID] else: print('ID number was not found.')

# save_load_dict.py import pickle

# Implementation of pickle it function def pickle_it(employees):

# Open file out = open('employees.dat','wb') pickle.dump(employees, out) out.close()

# Implementation of unpickle it function def unpickle_it(): try:

# open file infile = open('employees.dat',('rb') except IOError: file = open('employees.dat','wb') file.close() infile = open('employelees.dat','rb')

# Load employees dictionary try: employees = pickle.load(infile) except: employees={} # Close file infile.close() return employees

137 def change(eployees) 39 Prompt and road the 10 Tron uscn 14 IDinput'Enter an employe ID nuber: 141 f ID in enplcyeas: 144 naninput Entcr the cnplcye's nanc:) 145 department. ngut('Enter theenployee\'s Jepartment:') 4 1ab tila nput Entor tha cuployet's jab titla: 48pdate the entry 49 atployces[ID].sat nanc(nane) 5 eployeesLIDI,set departmenet (departnent 51 orplayos [ID].stja_titlojo title) rint(D nuter was not found. tation oF 57 def delete(eployees) S9 Prompt and road I0 Iron the uscn 16 Iirput'Enter an enployee ID nurber:) 61 f Iin enplayos: del erployees I0 print( ID nurber was not found. 166 # save-laaddict.py import pickle >>> %Run Employee Management System. py Syntaxrror: invalid syntax 10/81/2013

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

Advances In Databases And Information Systems 22nd European Conference Adbis 2018 Budapest Hungary September 2 5 2018 Proceedings Lncs 11019

Authors: Andras Benczur ,Bernhard Thalheim ,Tomas Horvath

1st Edition

3319983970, 978-3319983974

Students also viewed these Databases questions

Question

Question What is the advantage of a voluntary DBO plan?

Answered: 1 week ago

Question

Question How is life insurance used in a DBO plan?

Answered: 1 week ago