📖 Scenario
Instead of writing separate code for each student, create a Class — a blueprint. Then create individual student objects from it. A Topper subclass inherits everything from Student and adds scholarship logic. This is the core idea of OOP!
Starter Code
class Student:
def __init__(self, name, roll_no, marks):
pass # store name, roll_no, marks using self
def get_grade(self):
pass # return 'A', 'B', or 'C'
def display(self):
pass # print name, roll no, marks, grade
class Topper(Student):
def __init__(self, name, roll_no, marks):
pass # call super().__init__ here
def get_scholarship(self):
pass # return scholarship amount
Your Tasks
- Fill
__init__ — store name, roll_no, marks using self
- Fill
get_grade() — return "A" if marks>=80, "B" if marks>=60, else "C"
- Fill
display() — print all info neatly, call self.get_grade() inside it
- Fill
Topper.__init__ — call super().__init__() so it inherits from Student
- Fill
get_scholarship() — "₹10,000" if marks>=90, else "No scholarship"
Expected Output
s1 = Student("Rahul", 101, 75) → s1.display()
Rahul | Roll: 101 | Marks: 75 | Grade: B
t1 = Topper("Sneha", 102, 95) → t1.display()
Sneha | Roll: 102 | Marks: 95 | Grade: A
t1.get_scholarship() → ₹10,000
💡 One Hint
Every method in a class needs
self as its first parameter.
self.name = name saves the value to the object. In Topper, don't forget
super().__init__(name, roll_no, marks) — otherwise name/marks won't be set!