Question #248875

Suppose there is XYZ Company and there are different departments like production, marketing, finance, sales etc. Manager of the company want to know about the detail of the employees who are highly paid in each of the department. Write a program using the concept of classes to implement the same

Expert's answer

class XYZ:
    def __init__(self, department, salary):
        self.department = department
        self.salary = salary
    def __str__(self) -> str:
        return f"Department: {self.department} Salary: {self.salary}\n"


e1 = str(XYZ("production", 120))
e2 = str(XYZ("marketing", 300))
e3 = str(XYZ("finance", 250))
e4 = str(XYZ("sales", 100))
print(e1, e2, e3, e4)

Example:
Department: production Salary: 120
 Department: marketing Salary: 300
 Department: finance Salary: 250
 Department: sales Salary: 100

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

LATEST TUTORIALS
APPROVED BY CLIENTS