GOEDUHUB Online Courses || Last Batch Student's Projects || COVID-19 Projects(AI-ML) || Universities  ||  Placement Preparation  Subscribe our youtube channel
+91-7976731765 Free Online Tutorials ||  MACHINE LEARNING || Python || DBMS || OOPs || DSA || Java || Linux/Unix ||  C Programming
Register For Online Free Certified Workshops 
0 like 0 dislike
in Python Programming by Goeduhub's Expert (8k points)

1 Answer

0 like 0 dislike
by Goeduhub's Expert (8k points)
Best answer

Python is an object oriented programming language.

  • Almost everything in Python is an object, with its properties and methods.
  • A Class is like an object constructor, or a blueprint for creating objects.


Class is a set or category of things having some property or attribute in common and differentiated from others by kind, type, or quality.

To create a class, use the keyword class

Example-create a class named Firstclass , with a property named x:

class FirstClass:



<class '__main__.FirstClass'>


Object is one of instances of the class which can perform the functionalities which are defined in the class.

Now we can use the class named FirstClass to create objects

Example- Create object named o1 and print the value of x. Here object o1 can access x value.




The __init__() function

  • We have gone through Classes and objects in their simplest form, and are not really useful in real life applications.

  • To understand the meaning of classes we have to understand the built-in __init__() function.

  • All classes have a function called __init__(), which is always executed when the class is being initiated.

  • Use the __init__() function to assign values to object properties, or other operations that are necessary to do when the object is being created:

Example-Create a class named Student and use the init() function to assign values for name and age. 

class Student:

    def __init__(self, name, age):

        self.name = name

        self.age = age

p1 = Student("Smith", 16)



Smith 16

Related questions

1 like 0 dislike
6 answers 429 views
1 like 0 dislike
1 answer 43 views
1 like 0 dislike
1 answer 20 views
asked Oct 11, 2019 in Python Programming by Goeduhub Goeduhub's Expert (8k points)
0 like 0 dislike
5 answers 300 views
0 like 0 dislike
1 answer 39 views
 Placements:   List of companies | Logical Reasoning Questions | Quantitative Aptitude Questions | General English Questions | Technical-MCQ and Interview Questions
 Important Lists: List of NITsList of IITsList of Exams After Graduation | List of Engineering Entrance Examinations (UG/PG)College ReviewsCollege Fest, Events & WorkshopsKnowledge ShareTrainees/Interns After 15-04-2020
Exams & Cutoffs: JEE Main | JEE Advanced | GATE | IES | ISROList of PSUs || Cutoff-GATECutoff_IIT-JEECS-ScopeECE ScopeEE-Scope
 Download Previous Year Papers For:  GATE | IES | RAJASTHAN TECHNICAL UNIVERSITY (RTU-Kota)RPSC Technical Exams | ISRO
About Us | Contact Us   Social::   |  |