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
Comments
Leave a comment