From 39a0977e2d904fff50abbe535715ed95ce102d96 Mon Sep 17 00:00:00 2001 From: firecoder <150460783+Firesoulcoder@users.noreply.github.com> Date: Sun, 7 Jan 2024 16:11:22 +0530 Subject: [PATCH] Adding comments minor comments --- samples/oop_basic/student.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/samples/oop_basic/student.py b/samples/oop_basic/student.py index 8a832ff0..bb7708dd 100755 --- a/samples/oop_basic/student.py +++ b/samples/oop_basic/student.py @@ -1,16 +1,25 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- -class Student(object): +class Student: + """ + Represents a student with a name and score. + """ def __init__(self, name, score): self.name = name self.score = score def print_score(self): - print('%s: %s' % (self.name, self.score)) + """ + Prints the student's name and score. + """ + print(f'{self.name}: {self.score}') def get_grade(self): + """ + Returns the grade based on the student's score. + """ if self.score >= 90: return 'A' elif self.score >= 60: @@ -21,9 +30,9 @@ def get_grade(self): bart = Student('Bart Simpson', 59) lisa = Student('Lisa Simpson', 87) -print('bart.name =', bart.name) -print('bart.score =', bart.score) +print('bart.name:', bart.name) +print('bart.score:', bart.score) bart.print_score() -print('grade of Bart:', bart.get_grade()) -print('grade of Lisa:', lisa.get_grade()) +print('Grade of Bart:', bart.get_grade()) +print('Grade of Lisa:', lisa.get_grade())