python define class
class Mammal:
def __init__(self, name):
self.name = name
def walk(self):
print(self.name + " is going for a walk")
class Dog(Mammal):
def bark(self):
print("bark!")
class Cat(Mammal):
def meow(self):
print("meow!")
dog1 = Dog("Spot")
dog1.walk()
dog1.bark()
cat1 = Cat("Juniper")
cat1.walk()
cat1.meow()
class a_class:
#This initalizes the object, and is executed when you define
#a new object in the class
def __init__(self, input1):
self.__input1 = input1
#This is a function of the object that can be called
def return_input(self):
return self.__input1
a_class_object = a_class("input string")
print(a_class_object.return_input())