__init__()

Total Post:57

Points:285
Python 
 504  View(s)
Ratings:
Rate this:
  1. Post:57

    Points:285
    __init__()

    The __init__() Function:

    classes and objects in their simplest form are not really useful in real life applications. It's a built-in __init__() function. 

    Example :        

    Use the __init__() function to assign values for name and age:

    class Person: 
      def __init__(self, name, age):
        self.name = name
        self.age = age
    p1 = Person("Prakash", 19)
    print(p1.name)
    print(p1.age)

Answer