Skip to content

Commit d380b93

Browse files
authored
Update README.md
1 parent 00f59a1 commit d380b93

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

exercises/042-understanding_classes/README.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,16 @@ class Student:
1414
self.grade = grade
1515

1616
def introduce(self): # This is a method
17-
print(f"Hello! I am {self.name}, I am {self.age} years old, and my current grade is {self.grade}.")
17+
return f"Hello! I am {self.name}, I am {self.age} years old, and my current grade is {self.grade}."
1818

1919
def study(self, hours): # This is another method
20-
print(f"{self.name} is studying for {hours} hours.")
2120
self.grade += hours * 0.5
22-
print(f"After studying, {self.name}'s new grade is {self.grade}.")
21+
return f"After studying for {hours} hours, {self.name}'s new grade is {self.grade}."
2322

2423
student1 = Student("Ana", 20, 80)
2524

26-
student1.introduce()
27-
student1.study(3)
25+
print(student1.introduce())
26+
print(student1.study(3))
2827
```
2928

3029
In this code:
@@ -41,4 +40,4 @@ In this code:
4140

4241
+ Read about the `__init__` built-in function: https://www.w3schools.com/python/gloss_python_class_init.asp
4342

44-
+ If you find yourself wondering about the role of the `self` keyword in Python classes, take a moment to visit the following link for a detailed explanation: [Understanding the 'self' Parameter](https://www.geeksforgeeks.org/self-in-python-class/)
43+
+ If you find yourself wondering about the role of the `self` keyword in Python classes, take a moment to visit the following link for a detailed explanation: [Understanding the 'self' Parameter](https://www.geeksforgeeks.org/self-in-python-class/)

0 commit comments

Comments
 (0)