Skip to content

Commit 9d086eb

Browse files
committed
Fixes for typos and formatting errors in classes and classes concept exercise.
1 parent eb0e928 commit 9d086eb

6 files changed

Lines changed: 23 additions & 24 deletions

File tree

concepts/classes/about.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,10 @@ class Demo:
185185
The moment that `<object>.add_two()` is called, and `self.new_var += 2` is read, `new_var` changes from a class variable to an instance variable of the same name.
186186
187187
This can be useful during initialization when all instances of a class will need some attribute(s) to start with the same value.
188-
However, the instance variable then shadows* the class variable, making the class variable inaccessible from the instance where it is shadowed.
188+
However, the instance variable then [_shadows_](https://oznetnerd.com/2017/07/17/python-shadowing/) the class variable, making the class variable inaccessible from the instance where it is shadowed.
189189
Given this situation, it may be safer and clearer to set instance attributes from the `__init__()` method as `self.<attribute>`.
190190
~~~~
191-
_*[_shadows_][shadowing]
191+
192192

193193
## Methods
194194

@@ -240,7 +240,7 @@ class MyClass:
240240
def change_location(self, amount):
241241
self.location_x += amount
242242
self.location_y += amount
243-
return self.location_x, self.location_y
243+
return self.location_x, self.location_y
244244

245245
# Make a new test_object with location (3,7)
246246
>>> test_object = MyClass((3,7))
@@ -267,7 +267,7 @@ class MyClass:
267267
def change_location(self, amount):
268268
self.location_x += amount
269269
self.location_y += amount
270-
return self.location_x, self.location_y
270+
return self.location_x, self.location_y
271271

272272
# Alter class variable number for all instances from within an instance.
273273
def increment_number(self):
@@ -322,4 +322,3 @@ class MyClass:
322322
[dunder]: https://mathspp.com/blog/pydonts/dunder-methods
323323
[oop]: https://www.educative.io/blog/object-oriented-programming
324324
[dot notation]: https://stackoverflow.com/questions/45179186/understanding-the-dot-notation-in-python
325-
[shadowing]: https://oznetnerd.com/2017/07/17/python-shadowing/

exercises/concept/ellens-alien-game/.docs/hints.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
## 4. The `teleport` Method
2121

2222
- Remember that `object methods` are always passed `self` as the first parameter.
23-
- Instance attributes can be updated from a method by using `self.<attribute>` = `<new attribute value>`.
23+
- Instance attributes can be updated from a method by using `self.<attribute> = <new attribute value>`.
2424

2525
## 5. The `collision_detection` Method
2626

@@ -39,4 +39,4 @@
3939
- A `tuple` would be a _single_ parameter.
4040
- The Alien constructor takes _2 parameters_.
4141
- Unpacking what is _inside_ the tuple would yield two parameters.
42-
- The standalone function is outside of the `class`
42+
- The standalone function is outside of the `class`.

exercises/concept/ellens-alien-game/.docs/instructions.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ It is up to you if `hit()` takes healths points _to_ or _below_ zero.
3131

3232
```python
3333
>>> alien = Alien(0, 0)
34-
>>> alien.health
3534

3635
# Initialized health value.
36+
>>> alien.health
3737
3
3838

3939
# Decrements health by 1 point.
@@ -103,8 +103,8 @@ For example:
103103
2
104104
>>> alien_one.total_aliens_created
105105
2
106-
>>> Alien.total_aliens_created
107106
# Accessing the variable from the class directly
107+
>>> Alien.total_aliens_created
108108
2
109109
```
110110

@@ -120,7 +120,7 @@ For example:
120120
>>> aliens = new_aliens_collection(alien_start_positions)
121121
...
122122
>>> for alien in aliens:
123-
print(alien.x_coordinate, alien.y_coordinate)
123+
... print(alien.x_coordinate, alien.y_coordinate)
124124
(4, 7)
125125
(-1, 0)
126126
```

exercises/concept/ellens-alien-game/.docs/introduction.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ class MyClass:
182182
def change_location(self, amount):
183183
self.location_x += amount
184184
self.location_y += amount
185-
return self.location_x, self.location_y
185+
return self.location_x, self.location_y
186186

187187
# Make a new test_object with location (3,7)
188188
>>> test_object = MyClass((3,7))
@@ -209,7 +209,7 @@ class MyClass:
209209
def change_location(self, amount):
210210
self.location_x += amount
211211
self.location_y += amount
212-
return self.location_x, self.location_y
212+
return self.location_x, self.location_y
213213

214214
# Alter class variable number for all instances from within an instance.
215215
def increment_number(self):

exercises/concept/ellens-alien-game/.meta/exemplar.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ class Alien:
66
77
Attributes:
88
(class) total_aliens_created (int): Total number of Alien instances.
9-
x_coordinate (int): Position on the x-axis.
9+
x_coordinate (int): Position on the x-axis.
1010
y_coordinate (int): Position on the y-axis.
11-
health (int): Number of health points.
11+
health (int): Number of health points.
1212
1313
Methods:
1414
hit(): Decrement Alien health by one point.
@@ -29,9 +29,9 @@ def __init__(self, x_coordinate, y_coordinate):
2929
health (int): Number of health points.
3030
3131
Attributes:
32-
x_coordinate (int): Position on the x-axis.
32+
x_coordinate (int): Position on the x-axis.
3333
y_coordinate (int): Position on the y-axis.
34-
health (int): Number of health points. Defaults to 3.
34+
health (int): Number of health points. Defaults to 3.
3535
3636
Returns:
3737
Alien (Alien Object): New Alien.
@@ -59,7 +59,7 @@ def is_alive(self):
5959
"""Return if the Alien is alive.
6060
6161
Returns:
62-
bool: Is the Alien Alive?
62+
bool: Is the Alien Alive?
6363
"""
6464

6565
return self.health > 0
@@ -94,11 +94,11 @@ def collision_detection(self, other):
9494
def new_aliens_collection(positions):
9595
"""Create a list of Alien instances from a list of coordinate tuples.
9696
97-
Parameters:
98-
positions (list[tuple]): List of (x, y) coordinates in tuples..
97+
Parameters:
98+
positions (list[tuple]): List of (x, y) coordinates in tuples.
9999
100-
Returns:
101-
list[object]: List of Alien objects.
100+
Returns:
101+
list[object]: List of Alien objects.
102102
"""
103103

104104
return [Alien(position[0], position[1]) for position in positions]

exercises/concept/ellens-alien-game/classes.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ class Alien:
66
77
Attributes:
88
(class) total_aliens_created (int): Total number of Alien instances.
9-
x_coordinate (int): Position on the x-axis.
9+
x_coordinate (int): Position on the x-axis.
1010
y_coordinate (int): Position on the y-axis.
11-
health (int): Number of health points.
11+
health (int): Number of health points.
1212
1313
Methods:
1414
hit(): Decrement Alien health by one point.
@@ -21,5 +21,5 @@ class Alien:
2121
pass
2222

2323

24-
#TODO (Student): Create the new_aliens_collection() function below to call your Alien class with a list of coordinates
24+
#TODO (Student): Create the new_aliens_collection() function below to call your Alien class with a list of coordinates
2525

0 commit comments

Comments
 (0)