Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Hello, there is currently an error in my code where I am told the following:

 

Traceback (most recent call last):
  File "C:/Users/thepe/PycharmProjects/CPE101Labs/Dunder Mifflin/Employee Managment/employee.py", line 1, in <module>
    class employee:
  File "C:/Users/thepe/PycharmProjects/CPE101Labs/Dunder Mifflin/Employee Managment/employee.py", line 67, in employee
    employeeList.append(employeeList("Michael", 45, "Manager"))
TypeError: 'list' object is not callable

 

 

Here's my code:

class employee:

def __init__(self, name, age, position):
self.name = name
self.age = age
self.position = position


def display_employees(listOfEmployees):
print()
print("Employees in Dunder Mifflin are:")
print()
for item in listOfEmployees:
print(item.name + ",", str(item.age) + ",", item.position)


def allocate_department(listOfEmployees):
allocatedList = []
managementList = []
salesList = []
accountantList =[]
for employee in listOfEmployees:
if employee.positon == "Manager" or "Manager" in employee.position:
managementList.append(employee)
elif employee.position == "Salesperson" or "Salesperson" in employee.position:
salesList.append(employee)
elif employee.position == "Accountant" or "Accountant" in employee.position:
accountantList.append(employee)
else:
pass
allocatedList.append(managementList)
allocatedList.append(salesList)
allocatedList.append(accountantList)
return allocatedList


def display_department_employees(listOfDep):
print()
print("The individual employees in each department are shown below:")
print("-----------------------------------------------------------")
print()
n = 1
for dep in listOfDep:
if n == 1:
print("Management")
print("----------")
elif n == 2:
print("Salespersons:")
print("-------------")
for emp1 in dep:
print(emp1.name + ",", str(emp1.age), + ",", emp1.position)
print()
n += 1


def head_of_department(listOfDep):
for dep in listOfDep:
max = 0
for emp1 in dep:
if emp1.age > max:
max = emp1.age
for emp1 in dep:
if max == emp1.age:
emp1.position = "Head" + emp1.position

employeeList = []
employeeList.append(employeeList("Michael", 45, "Manager"))
employeeList.append(employeeList("Dwight", 40, "Assistant to the Manager"))
employeeList.append(employeeList("Jim", 35, "Manager"))
employeeList.append(employeeList("Pam", 30, "Receptionist"))
employeeList.append(employeeList("Angela", 32, "Accountant"))
employeeList.append(employeeList("Kevin", 42, "Accountant"))
employeeList.append(employeeList("Oscar", 40, "Accountant"))
employeeList.append(employeeList("Stanley", 55, "Salesperson"))
employeeList.append(employeeList("Phyllis", 45, "Salesperson"))
employeeList.append(employeeList("Andy", 38, "Salesperson"))
employeeList.append(employeeList("Ryan", 30, "Salesperson"))
employeeList.append(employeeList("Creed", 55, "Salesperson"))

employeeList.display_employees(employeeList)
employeeList.display_department_employees(employeeList.allocate_department(employeeList))
employeeList.head_of_department(employeeList.allocate_department(employeeList))
print("#####################################")
print("Head of department allocation done!!!")
print("#####################################")
employeeList.display_department_employees(employeeList.allocate_department(employeeList))
print()

9 File Edit View Navigate Code Refactor Run Iools VCS Window Help
conditonalmidterm_funcs.py - Employee Managment\employee.py
CPE101Labs
Dunder Mifflin) Employee Managment o employee.py
employee (1) ▼
Employee Managment\employee.py
Lab 8\employee.py
e Colision Detection.py X
aclass employee:
A 9 A 10 Y 1 ^ v
3
def init (self, name, age, position):
self.name = name
self.age = age
self.position = position
5
6
8
def display_employees(list0fEmployees):
print()
9
10
11
print("Employees in Dunder Mifflin are:")
12
print()
13
for item in list0fEmployees:
14
print(item.name +
",", str(item.age) + ",", item.position)
15
16
17
def allocate_department(list0fEmployees):
18
allocatedList = []
19
managementList = []
20
saleslist = []
21
accountantList =[]
22
for employee in list0fEmployees:
23
if employee.positon == "Manager" or "Manager" in employee.position:
managementList.append(employee)
24
25
elif employee.position == "Salesperson" or "Salesperson" in employee.position:
salesList.append(employee)
elif employee.position == "Accountant" or "Accountant" in employee.position:
accountantList.append (employee)
26
27
28
29
else:
30
pass
31
allocatedList.append(managementList)
allocatedList.append (salesList)
32
33
allocatedList.append(accountantList)
34
return allocatedList
35
36
- 37
def display_department_employees(list0fDep):
print()
38
39
print("The individual employees in each department are shown below:")
* 40
print("
')
employee
allocate_department()
for employee in listOfEmployees
if employee.positon == "Manager.
> Run
E TODO
O Problems
2 Terminal
S Python Packages
e Python Console
1 Event Log
O Packages installed successfully: Installed packages: 'employee' (20 minutes ago)
24:41 CRLF UTF-8 4 spaces Python 3.8 (CPE101Labs) 1
4:57 PM
12/1/2021
★ Favorites
Transcribed Image Text:9 File Edit View Navigate Code Refactor Run Iools VCS Window Help conditonalmidterm_funcs.py - Employee Managment\employee.py CPE101Labs Dunder Mifflin) Employee Managment o employee.py employee (1) ▼ Employee Managment\employee.py Lab 8\employee.py e Colision Detection.py X aclass employee: A 9 A 10 Y 1 ^ v 3 def init (self, name, age, position): self.name = name self.age = age self.position = position 5 6 8 def display_employees(list0fEmployees): print() 9 10 11 print("Employees in Dunder Mifflin are:") 12 print() 13 for item in list0fEmployees: 14 print(item.name + ",", str(item.age) + ",", item.position) 15 16 17 def allocate_department(list0fEmployees): 18 allocatedList = [] 19 managementList = [] 20 saleslist = [] 21 accountantList =[] 22 for employee in list0fEmployees: 23 if employee.positon == "Manager" or "Manager" in employee.position: managementList.append(employee) 24 25 elif employee.position == "Salesperson" or "Salesperson" in employee.position: salesList.append(employee) elif employee.position == "Accountant" or "Accountant" in employee.position: accountantList.append (employee) 26 27 28 29 else: 30 pass 31 allocatedList.append(managementList) allocatedList.append (salesList) 32 33 allocatedList.append(accountantList) 34 return allocatedList 35 36 - 37 def display_department_employees(list0fDep): print() 38 39 print("The individual employees in each department are shown below:") * 40 print(" ') employee allocate_department() for employee in listOfEmployees if employee.positon == "Manager. > Run E TODO O Problems 2 Terminal S Python Packages e Python Console 1 Event Log O Packages installed successfully: Installed packages: 'employee' (20 minutes ago) 24:41 CRLF UTF-8 4 spaces Python 3.8 (CPE101Labs) 1 4:57 PM 12/1/2021 ★ Favorites
PC File Edit View Navigate Code Refactor Run Iools VCS Window Help
conditonalmidterm_funcs.py - Employee Managment\employee.py
CPE101Labs Dunder Mifflin Employee Managment fe employee.py
employee (1) ▼
Employee Managment\employee.py
י"ההביושר
Lab 8\employee.py
e Colision Detection.py X
A 9 A 10 Y 1 ^ v
50
for emp1 in dep:
print(emp1.name +
',", str(emp1.age),
",", emp1.position)
51
52
print()
53
n += 1
54
55
def head_of_department(list0fDep):
for dep in list0fDep:
56
57
58
max = 0
59
for emp1 in dep:
60
if emp1.age > max:
61
max = emp1.age
62
for emp1 in dep:
63
if max == emp1.age:
64
emp1.position = "Head" + emp1.position
65
employeelist = []
employeeList.append(employeeList("Michael", 45, "Manager"))
66
67
68
employeeList.append(employeeList("Dwight", 40, "Assistant to the Manager"))
employeeList.append(employeeList("Jim", 35, "Manager"))
69
70
employeeList.append(employeeList("Pam", 30, "Receptionist"))
71
employeeList.append(employeeList("Angela", 32, "Accountant"))
72
employeeList.append(employeeList("Kevin", 42, "Accountant"))
73
employeeList.append(employeeList("0scar", 40, "Accountant"))
74
employeeList.append(employeeList("Stanley", 55, "Salesperson"))
75
employeelist.append(employeeList("Phyllis", 45, "Salesperson"))
76
employeeList.append(employeeList("Andy", 38, "Salesperson"))
77
employeeList.append(employeeList("Ryan", 30, "Salesperson"))
78
employeeList.append(employeeList("Creed", 55, "Salesperson"))
79
80
employeeList.display_employees(employeeList)
81
employeeList.display_department_employees(employeeList.allocate_department(employeeList))
82
employeeList.head_of_department(employeeList.allocate_department(employeelist))
83
print("#####################################")
84
print("Head of department allocation done!!!")
85
print("#####################################")
86
employeelist.display_department_employees(employeeList.allocate_department(employeeList))
8 87
print()
allocate_department()
O Problems
O Packages installed successfully: Installed packages: 'employee' (20 minutes ago)
employee
for employee in listOfEmployees
if employee.positon == "Manager.
> Run
E TODO
2 Terminal
S Python Packages
2 Python Console
1 Event Log
24:41 CRLF UTF-8 4 spaces Python 3.8 (CPE101Labs) 1
4:58 PM
x ロ
12/1/2021
Favorites
Transcribed Image Text:PC File Edit View Navigate Code Refactor Run Iools VCS Window Help conditonalmidterm_funcs.py - Employee Managment\employee.py CPE101Labs Dunder Mifflin Employee Managment fe employee.py employee (1) ▼ Employee Managment\employee.py י"ההביושר Lab 8\employee.py e Colision Detection.py X A 9 A 10 Y 1 ^ v 50 for emp1 in dep: print(emp1.name + ',", str(emp1.age), ",", emp1.position) 51 52 print() 53 n += 1 54 55 def head_of_department(list0fDep): for dep in list0fDep: 56 57 58 max = 0 59 for emp1 in dep: 60 if emp1.age > max: 61 max = emp1.age 62 for emp1 in dep: 63 if max == emp1.age: 64 emp1.position = "Head" + emp1.position 65 employeelist = [] employeeList.append(employeeList("Michael", 45, "Manager")) 66 67 68 employeeList.append(employeeList("Dwight", 40, "Assistant to the Manager")) employeeList.append(employeeList("Jim", 35, "Manager")) 69 70 employeeList.append(employeeList("Pam", 30, "Receptionist")) 71 employeeList.append(employeeList("Angela", 32, "Accountant")) 72 employeeList.append(employeeList("Kevin", 42, "Accountant")) 73 employeeList.append(employeeList("0scar", 40, "Accountant")) 74 employeeList.append(employeeList("Stanley", 55, "Salesperson")) 75 employeelist.append(employeeList("Phyllis", 45, "Salesperson")) 76 employeeList.append(employeeList("Andy", 38, "Salesperson")) 77 employeeList.append(employeeList("Ryan", 30, "Salesperson")) 78 employeeList.append(employeeList("Creed", 55, "Salesperson")) 79 80 employeeList.display_employees(employeeList) 81 employeeList.display_department_employees(employeeList.allocate_department(employeeList)) 82 employeeList.head_of_department(employeeList.allocate_department(employeelist)) 83 print("#####################################") 84 print("Head of department allocation done!!!") 85 print("#####################################") 86 employeelist.display_department_employees(employeeList.allocate_department(employeeList)) 8 87 print() allocate_department() O Problems O Packages installed successfully: Installed packages: 'employee' (20 minutes ago) employee for employee in listOfEmployees if employee.positon == "Manager. > Run E TODO 2 Terminal S Python Packages 2 Python Console 1 Event Log 24:41 CRLF UTF-8 4 spaces Python 3.8 (CPE101Labs) 1 4:58 PM x ロ 12/1/2021 Favorites
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Storage Devices
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education