Example Class in Python:
Create an account for 3 different departments + give me (print,display) example of name belongs to each department.
- Management
- Sales
- Accountant
Each account has Name, department, and email common attribute to have.
Solution:
class Account:
def __init__(self,name,department,email):
self.name = name
self.department = department
self.email = email
mang = Account("Oliver","Tech Support","oliver.rich@example.com")
sale = Account("Abbas","Sales","abbas@example.com")
acco = Account("Abdul","Accountants","abdul@isb.com")
print(f”Example of Manager, the name of the manager is: {mang.name} , and the department is: {mang.department}”)
Output:
Example of Manager, the name of the manager is: Oliver , and the department is: Tech Support