Instantiating a class is creating a copy of the class which inherits all class variables and methods. Instantiating a class in Python is simple. To instantiate a class, we simply call the class as if it were a function, passing the arguments that the init method defines. The return value will be the newly created object.

Machine Problem in Python

  1. Create a Class called Employee
  2. Use the init function to collect the employee information
    a. Name, email and mobile number
  3. Instantiate the Employee class two times with different information
  4. Display all the properties of the object.

Program Listing

# Author : Jake R. Pomperada

class Employee:
    def __init__(self, name, email, mobile):
        self.pangalan = name = email = mobile

jp = Employee("Jake Pomperada", "", "09123612561")
mj = Employee("Michael Jordan", "", "09671722123")

print(f"Name: {jp.pangalan} | Email: {} | Mobile Number: {}")
print(f"Name: {mj.pangalan} | Email: {} | M

Leave a Reply

Your email address will not be published.