The following code shows how to Example to Create a Class in Python.
# Defining a class in python
class Institute:
def __init__(self, iname, no_of_courses, established):
self.iname=iname
self.no_of_courses=no_of_courses
self.established=established
def getIname(self):
print("Institute Name: "+self.iname)
def getCourses(self):
print("Number of courses in the institute: "+str(self.no_of_courses))
def getEstablished(self):
print("Institute established in the year "+str(self.established))
# creating an object in python
iob=Institute('IT Institute', 6, 2002)
print("What is the name of this institute?")
iob.getIname()
print("How many courses are there in this institute?")
iob.getCourses()
print("In which year it is established?")
iob.getEstablished()
Output
![The Output of the Example to Create a Class in Python](https://www.programmingempire.com/wp-content/uploads/2022/04/image-24.png)
Further Reading
Deep Learning Methods for Object Detection
Examples of OpenCV Library in Python
- Angular
- ASP.NET
- C
- C#
- C++
- CSS
- Dot Net Framework
- HTML
- IoT
- Java
- JavaScript
- Kotlin
- PHP
- Power Bi
- Python
- Scratch 3.0
- TypeScript
- VB.NET
![programmingempire](https://www.programmingempire.com/wp-content/uploads/2021/10/pefavicon.png)