instantiate a class python code example

Example: python instantiate class

# To instantiate a class, you need to have a __init__ function inside the class
# Example:
class Human(object):
  
    def __init__(self, name, age): # Here is that function I was talking about
        # It sets some variables so I can use them in other functions in this class.
        self.name = name
        self.age = age
    
    def say_name(self):
        print(f"My name is {self.name}.")
    
    def say_age(self):
        print(f"My age is {self.age}.")

bob = Human("Bob", 28)
bob.say_name()
bob.say_age()