📎 Referral Code:
—
📊 Dashboard
Sign In
Regular
Python
Live Classes
Courses
Assignments
Q & A
My Profile
Recruiter Board
Job Support
Career Preparation
🎯
Interview Board
Real Q&As from top companies
Popular
Placement Support
🧑
Interview Support
Check Interview or Documents
Available
Class Room
AI Tools
AI Agents
🌐
Project Explanation Agent
Find tutorials & docs instantly
New
Support Works
Sign In
Sign Up Free
Navigation
🗺️
Live Classes
🗺️
Courses
🎬
Assignments
💡
Q & A
💡
My Profile
💡
Recruiter Board
Job Support
🎯
Interview Board
AI Tools
🌐
Project Explanation Agent
🛟
Support Works
Sign In
Sign Up Free →
Home
›
Python Basics in English
Python Class Design
Python Basics in English
›
Python Class Design
Python Class Design
Python Basics in English
.
Now Watching
Previous
← Previous
Python Function Design
Lesson Progress
Next →
Class Variables
Next
📄 View Reference Document & Notes
📋 Lesson Notes & Resources
Python Class – Key Concepts & Syntax
Concepts covered: What is a class, keywords, syntax, constructor, parameter types, and function types.
1. What is a Class?
A
class
is a blueprint or template used to create objects. It groups related
data
(variables) and
behaviour
(functions) into a single unit.
Class
→ Blueprint / design
Object (Instance)
→ Real thing created from the blueprint
OOP Concepts
used in classes:
Encapsulation – keeping data and functions together
Inheritance – reusing code from a parent class
Polymorphism – same function name, different behaviours
Abstraction – hiding internal complexity, showing only what is required
2. Important Keywords & Concepts in Python Classes
class
– used to define a new class.
self
– refers to the current object (instance) inside class methods.
__init__
– constructor method, called automatically when an object is created.
object
– base class of all classes in Python (in practice we often just write
class MyClass:
).
@classmethod
– decorator for class methods which receive
cls
instead of
self
.
@staticmethod
– decorator for static methods that don’t use
self
or
cls
.
@property
– decorator to create getter-like methods that work like attributes.
3. Basic Class Syntax
General structure of a simple class in Python:
class
ClassName
:
# class variables (optional)
class_variable
=
10
def
__init__
(
self
,
param1
,
param2
):
# instance variables
self
.
attr1
=
param1
self
.
attr2
=
param2
def
instance_method
(
self
):
return
self
.
attr1
Creating an object from the class:
obj
=
ClassName
(
"value1"
,
"value2"
)
4. Constructor –
__init__
The constructor is a special method named
__init__
which runs automatically when we create an object. It is used to
initialize instance variables
.
class
Student
:
def
__init__
(
self
,
name
,
course
):
self
.
name
=
name
self
.
course
=
course
# object creation
s1
=
Student
(
"Rahul"
,
"Python"
)
First parameter must be
self
(reference to current object).
We pass values at object creation – they come into the constructor parameters.
Inside constructor we store data into
self
attributes (instance variables).
5. Parameter Types in Class Methods
Class methods (including constructor) can use all normal Python parameter types.
Positional parameters
Values are passed in order.
Default parameters
We give a default value in the method definition.
Keyword parameters
We pass values using
name=value
style.
*args
Collects extra positional arguments as a tuple.
**kwargs
Collects extra keyword arguments as a dictionary.
class
Order
:
def
__init__
(
self
,
order_id
,
# positional
status
=
"NEW"
,
# default
*
items
,
# *args
**
extra_info
# **kwargs
):
self
.
order_id
=
order_id
self
.
status
=
status
self
.
items
=
items
self
.
extra_info
=
extra_info
6. Function Types inside a Class
Inside a class, functions are called
methods
. Common types:
Instance methods
Most common. First parameter is
self
. Can access and modify object data.
Class methods
(
@classmethod
)
First parameter is
cls
(class itself). Often used as alternative constructors.
Static methods
(
@staticmethod
)
No
self
or
cls
. A normal function kept inside class for grouping.
Special / dunder methods
(like
__str__
,
__len__
)
Used to customize behaviour of built-in functions and operators.
class
BankAccount
:
def
__init__
(
self
,
owner
,
balance
=
0
):
self
.
owner
=
owner
self
.
balance
=
balance
# Instance method
def
deposit
(
self
,
amount
):
self
.
balance
+=
amount
# Class method
@classmethod
def
from_string
(
cls
,
data
):
owner
,
bal_str
=
data
.
split
(
","
)
return
cls
(
owner
,
float
(
bal_str
))
# Static method
@staticmethod
def
is_valid_amount
(
amount
):
return
amount
>=
0
7. Quick Summary
Use
class
to define a blueprint.
Use
__init__
as constructor to initialize data.
Always keep
self
as first argument in instance methods.
Use different parameter types (
*args
,
**kwargs
) for flexible input.
Use instance / class / static methods based on what you need to access (object, class, or none).
Course Content
10 lessons
Python Basics in English
1
Basics Introduction
.
2
Python Data Types
.
3
Python Data Operators
.
4
Python Function Design
.
▶
Python Class Design
.
6
Class Variables
.
7
Class Realtime Example
.
8
Inheritance Class
.
9
Abstract Class
.
10
Overview of the OOPS concept
.
All Course Lessons
01
Python Basics in English
›
💬 Connect with us
✕
🎁 Refer & Earn
💬 WhatsApp
Earn for every successful referral
₹1000
per student who enrolls
How it works
1
Share your referral code with a friend who wants to learn Python or AWS
2
They enroll using your code and pay for the course
3
You receive ₹1000 credited to your account
Login
to see your referral code and start earning.
💬
Chat with us on WhatsApp
Have a question about the course, fees, or career guidance? We reply quickly.
Usually replies within a few hours · Mon–Sat 9AM–8PM IST
Chat on WhatsApp
No spam — business queries only.
💬
2
👑
Unlock Premium Access
Get full access to
all recorded classes, assignments, Q&A board and online tests
. Join 500+ students learning Python & AWS.
Maybe later
🚀 Get Premium Access