You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: exercises/042-understanding_classes/README.es.md
+5-6Lines changed: 5 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -14,17 +14,16 @@ class Student:
14
14
self.grade = grade
15
15
16
16
defintroduce(self): # Esto es un método
17
-
print(f"Hello! I am {self.name}, I am {self.age} years old, and my current grade is {self.grade}.")
17
+
returnf"Hello! I am {self.name}, I am {self.age} years old, and my current grade is {self.grade}."
18
18
19
19
defstudy(self, hours): # Esto es otro método
20
-
print(f"{self.name} is studying for {hours} hours.")
21
20
self.grade += hours *0.5
22
-
print(f"After studying, {self.name}'s new grade is {self.grade}.")
21
+
returnf"After studying for {hours} hours, {self.name}'s new grade is {self.grade}."
23
22
24
23
student1 = Student("Ana", 20, 80)
25
24
26
-
student1.introduce()
27
-
student1.study(3)
25
+
print(student1.introduce())
26
+
print(student1.study(3))
28
27
```
29
28
30
29
En este código:
@@ -41,4 +40,4 @@ En este código:
41
40
42
41
+ Lee un poco sobre la función interna `__init__`: https://www.w3schools.com/python/gloss_python_class_init.asp
43
42
44
-
+ Si no comprendes la funcionalidad del parámetro `self` en el código que acabas de copiar, tómate un momento para visitar el siguiente enlace donde encontrarás una explicación detallada: [Entendiendo el parámetro 'self'](https://www.geeksforgeeks.org/self-in-python-class/)
43
+
+ Si no comprendes la funcionalidad del parámetro `self` en el código que acabas de copiar, tómate un momento para visitar el siguiente enlace donde encontrarás una explicación detallada: [Entendiendo el parámetro 'self'](https://www.geeksforgeeks.org/self-in-python-class/)
0 commit comments