Experiment 7
Experiment 7
Objectives: Implementing a Python program To understand the concept of Class and Objects.
Software Required:
1. Windows or Linux Desktop OS
2. Python 3.6 or higher
3. Google Colab
Theory:
Introduction to Object-Oriented Programming (OOP)
Object-Oriented Programming (OOP) is a programming paradigm based on the concept of "objects, "
which contain data (attributes) and functions (methods) that operate on that data.
What is a Class?
A class is a blueprint for creating objects. It defines a set of attributes (variables) and methods
(functions) that describe the behavior of the object.
Syntax of a Class :
class ClassName:
def __init__(self, param1, param2):
self.attribute1 = param1
self.attribute2 = param2
def method_name(self):
print("This is a method")
What is an Object?
An object is an instance of a class. It contains actual values stored in attributes and can access the
methods defined in the class.
Creating an Object :
obj = ClassName(value1, value2)
def display_info(self):
print(f"Student Name: {self.name}")
print(f"Age: {self.age}")
print(f"Course: {self.course}")
# Creating objects
student1 = Student("Amit", 21, "Information Technology")
student1.display_info()
Key Concepts
Result Analysis:
Conclusion: