Flat 10% & upto 50% off + Free additional Courses. Hurry up!

Python Classes


Class is a prototype for an object which defines a collection of attributes and these attributes are variable and methods which are accessed by dot. Class provides many features like:

  • Inheritance
  • Composition
  • Multiple instances
  • Customization via inheritance
  • Operator overloading


Create Classes

Keyword class is used to create the class. The basic structure of class is –

class <class_name> :

# Definition of class


Create Instance Objects


class Student:

s1 = 0

def __init__(self, id, name):

self.id = id

self.name = name


def showcount(self):

print "Total students are %d" % student.s1

def showstudent(self):

print "ID : ", self.id,  ", Name: ", self.name


st1 = Student (1,”abc”)

st2 = Student (2, ”pqr”)

st2 = Student (3, ”xyz”)


Access Attributes

Dot is used to access the attributes.




print "Total Students are %d" % Student.s1


ID: 1, abc

ID: 2, pqr

ID: 3, xyz

Total Students are 3

Learn more about PYTHON TOOLKIT in this insightful blog now!

"0 Responses on Python Classes"

Training in Cities

Bangalore, Hyderabad, Chennai, Delhi, Kolkata, UK, London, Chicago, San Francisco, Dallas, Washington, New York, Orlando, Boston

100% Secure Payments. All major credit & debit cards accepted Or Pay by Paypal.


Sales Offer

  • To avail this offer, enroll before 20th October 2016.
  • This offer cannot be combined with any other offer.
  • This offer is valid on selected courses only.
  • Please use coupon codes mentioned below to avail the offer


Sign Up or Login to view the Free Python Classes.