Skip to content

Commit 0403d36

Browse files
rename another Complex class → ComplexNumber
1 parent a5e4255 commit 0403d36

File tree

2 files changed

+3
-3
lines changed
  • Classes and objects

2 files changed

+3
-3
lines changed

Classes and objects/Special __init__ method/task.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ The `__init__()` method may receive arguments for greater flexibility.
2323
In that case, arguments given to the class instantiation operator are passed
2424
on to `__init__()`. For example:
2525
```python
26-
class Complex:
26+
class ComplexNumber:
2727
def __init__(self, real_part, imag_part):
2828
self.r = real_part
2929
self.i = imag_part
3030
self.num = complex(self.r, self.i)
3131

32-
x = Complex(3.0, -4.5) # Instantiating a complex number
32+
x = ComplexNumber(3.0, -4.5) # Instantiating a complex number
3333
x.num
3434
```
3535
```text

Classes and objects/__str__ vs __repr__/task.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ defined in the object's class.
2424

2525
Our own defined class should therefore have a `__repr__` if we need detailed information for debugging.
2626
Also, if we think it would be useful to have a string representation for users, we should create
27-
a `__str__` function. Check out another approach to representing complex numbers using the `ComplexNumber` class in the code editor. Run the code
27+
a `__str__` function. Check out another implementation of the class `ComplexNumber` in the code editor. Run the code
2828
to see what each of the two `print` statements prints.
2929

3030
For more structured and detailed information, you can refer to [this Hyperskill knowledge base page](https://hyperskill.org/learn/step/7139#str__-vs-__repr?utm_source=jba&utm_medium=jba_courses_links).

0 commit comments

Comments
 (0)