Learn practical skills, build real-world projects, and advance your career
Updated 4 years ago
Python Classes/Objects
Creating a Class
To create a class, use the keyword class:
class Student: # Base class/super class for all students
Count = 0 # student count
def __init__(self, name, rollno):
self.name = name
self.rollno = rollno
Student.Count += 1
def ShowCount(self):
print("Total Students: %d" % Student.Count)
def ShowStudent(self):
print("Name : ", self.name, ", Roll_no: ", self.rollno)
A class named Student, with different methods