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
Fixed some em-dashes that were actually hyphens, a few terms that were missing backticks, some indentation errors, one codeblock that didn't have closing triple-backticks, a few invalid links, some minor spacing errors, a few typos, one missing level-one header, one level-three header that should be a level-two header, one incorrectly wrapped paragraph, a few "-->"s that would be more clear as "to"s, a few headers that weren't surrounded by blank lines, one incorrectly placed ref-link, and one level-two heading that should be a level-one header.
Copy file name to clipboardExpand all lines: concepts/classes/about.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
`Classes` combine data with behavior.
4
4
Classes are used to create copies or `instances` of bundled data and behavior, commonly known as `objects`.
5
-
Objects can represent real world entities (_such as cars or cats_) - or more abstract concepts (_such as integers, vehicles, or mammals_).
5
+
Objects can represent real world entities (_such as cars or cats_) — or more abstract concepts (_such as integers, vehicles, or mammals_).
6
6
Classes are integral to an [object oriented programming][oop] (OOP) approach, which asks the programmer to think about modeling a problem as one or more objects that interact with one another, keep state, and act upon data.
7
7
8
8
## Classes
@@ -41,7 +41,7 @@ An instance (_object_) of `MyClass` can be created and bound to a name:
41
41
<__main__.MyClass at 0x15adc55b0>
42
42
```
43
43
44
-
`Class attributes` are shared across all objects (_or instances_) created from a class, and can be accessed via [`dot notation`][dot notation] - a `.` placed after the object name and before the attribute name:
44
+
`Class attributes` are shared across all objects (_or instances_) created from a class, and can be accessed via [`dot notation`][dot notation]— a `.` placed after the object name and before the attribute name:
45
45
46
46
```python
47
47
>>> new_object = MyClass()
@@ -66,7 +66,7 @@ True
66
66
```
67
67
68
68
Class attributes are defined in the body of the class itself, before any other methods.
69
-
They are owned by the class - allowing them to be shared across instances.
69
+
They are owned by the class — allowing them to be shared across instances.
70
70
Because these attributes are shared by all instances of the class, their value can be accessed and manipulated from the class directly.
71
71
Altering the value of class attributes alters the value _**for all objects instantiated from the class**_:
72
72
@@ -289,7 +289,7 @@ class MyClass:
289
289
290
290
In previous concept exercises and practice exercise stubs, you will have seen the `pass` keyword used within the body of functions in place of actual code.
291
291
292
-
The `pass` keyword is a syntactically valid placeholder - it prevents Python from throwing a syntax error for an empty function or class definition.
292
+
The `pass` keyword is a syntactically valid placeholder — it prevents Python from throwing a syntax error for an empty function or class definition.
293
293
Essentially, it is a way to say to the Python interpreter, 'Don't worry! I _will_ put code here eventually, I just haven't done it yet.'
Copy file name to clipboardExpand all lines: concepts/classes/introduction.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
Classes are definitions combining data (_otherwise known as `attributes`, `properties`,`data members`, `variables`, or `fields`_) with `functions` (_otherwise known as `methods`_).
4
4
Class definitions are used to create copies or `instances` of the `class`, commonly known as `objects`.
5
-
Objects can represent real world entities (_such as cars or cats_) - or more abstract concepts (_such as integers, vehicles, or mammals_).
5
+
Objects can represent real world entities (_such as cars or cats_) — or more abstract concepts (_such as integers, vehicles, or mammals_).
6
6
Each object is unique in computer memory and represents some part of an overall model.
7
7
Classes and objects can be found in several programming paradigms, but are integral to [object oriented programming][oop] (OOP), in which programs are made up of objects that interact with one another.
Copy file name to clipboardExpand all lines: concepts/comparisons/about.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -82,7 +82,7 @@ False
82
82
83
83
Strings (`str`) are compared [_lexicographically_][lexographic order], using their individual Unicode code points (_the result of passing each code point in the `str` to the built-in function [`ord()`][ord], which returns an `int`_).
84
84
If all code points in both strings match and are _**in the same order**_, the two strings are considered equal.
85
-
This comparison is done in a 'pair-wise' fashion - first-to-first, second-to-second, etc.
85
+
This comparison is done in a 'pair-wise' fashion — first-to-first, second-to-second, etc.
86
86
In Python 3.x, `str` and `bytes` cannot be directly coerced/compared.
87
87
88
88
```python
@@ -116,7 +116,7 @@ False
116
116
117
117
## Comparing Container Data Types
118
118
119
-
Container data types (_`lists`, `tuples`, `sets`, `dicts`, etc._) also compare [_lexicographically_][lexographic order]- they are equal if both containers have the same data **and** the same data types (_in the case of `lists` and `tuples`, they must also have the same **ordering**_), unequal otherwise.
119
+
Container data types (_`lists`, `tuples`, `sets`, `dicts`, etc._) also compare [_lexicographically_][lexographic order]— they are equal if both containers have the same data **and** the same data types (_in the case of `lists` and `tuples`, they must also have the same **ordering**_), unequal otherwise.
120
120
121
121
```python
122
122
>>> [1, 2] == [1, 2]
@@ -148,7 +148,7 @@ Comparison operators can be chained _arbitrarily_.
148
148
Note that the evaluation of an expression takes place from `left` to `right`.
149
149
For example, `x < y <= z` is equivalent to `x < y and y <= z`, except that `y` is evaluated **only once**.
150
150
In both cases, `z` is _not_ evaluated **at all** when `x < y` is found to be `False`.
151
-
This is often called `short-circuit evaluation`- the evaluation stops if the truth value of the expression has already been determined.
151
+
This is often called `short-circuit evaluation`— the evaluation stops if the truth value of the expression has already been determined.
152
152
153
153
`Short circuiting` is supported by various boolean operators, functions, and also by comparison chaining in Python.
154
154
Unlike many other programming languages, including `C`, `C++`, `C#`, and `Java`, chained expressions like `a < b < c` in Python have a conventional [mathematical interpretation][three way boolean comparison] and precedence.
Copy file name to clipboardExpand all lines: concepts/complex-numbers/about.md
+4-3Lines changed: 4 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -44,6 +44,7 @@ ValueError: complex() arg is a malformed string
44
44
>>> z2
45
45
(2+1.5j)
46
46
```
47
+
47
48
The end result is identical to using the `complex()` constructor.
48
49
49
50
@@ -98,6 +99,7 @@ However, it is still a complex number in Python:
98
99
You may have heard that "`i` (or `j`) is the square root of -1".
99
100
100
101
For now, all this means is that the imaginary part _by definition_ satisfies the equality
102
+
101
103
```python
102
104
1j*1j==-1# => True
103
105
```
@@ -148,7 +150,7 @@ Integer division is ___not___ possible on complex numbers, so the `//` and `%` o
148
150
149
151
There are two functions implemented for numeric types that are very useful when working with complex numbers:
150
152
151
-
-`<complex number>.conjugate()` simply flips the sign of the imaginary part of a complex number (_from + to - or vice-versa_).
153
+
-`<complex number>.conjugate()` simply flips the sign of the imaginary part of a complex number (_from `+` to `-` or vice-versa_).
152
154
- Because of the way complex multiplication works, this is more useful than you might think.
153
155
-`abs(<complex number>)` is guaranteed to return a real number with no imaginary part.
154
156
@@ -212,7 +214,7 @@ It was strange and new in the 16th century.
212
214
### Why would anyone use these?
213
215
214
216
It turns out that complex numbers are the simplest way to describe anything that rotates or anything with a wave-like property.
215
-
So they are used widely in electrical engineering, audio processing, physics, computer gaming, and navigation - to name only a few applications.
217
+
So they are used widely in electrical engineering, audio processing, physics, computer gaming, and navigation — to name only a few applications.
216
218
217
219
You can see things rotate.
218
220
Complex numbers may not make the world go round, but they are great for explaining _what happens_ as a result of the world going round: look at any satellite image of a major storm.
@@ -257,4 +259,3 @@ So, you are probably using technology that relies on complex number calculations
Most decorators are intended to _extend_ or _replace_ the behavior of another function, but some decorators may do nothing but return the functions they are wrapping.
73
73
74
-
Decorators are functions which take at least one argument - the function which they are wrapping.
74
+
Decorators are functions which take at least one argument — the function which they are wrapping.
75
75
They usually return either the wrapped function or the result of an expression that uses the wrapped function.
76
76
77
-
A simple decorator - one that simply returns its wrapped function - can be written as follows:
77
+
A simple decorator — one that simply returns its wrapped function — can be written as follows:
Copy file name to clipboardExpand all lines: concepts/functions/introduction.md
+9-7Lines changed: 9 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,13 +5,13 @@ Functions are used to perform specific and repetitive tasks.
5
5
6
6
More formally: a function is any Python object to which the [`function call`][calls] operation can be applied.
7
7
A function may be used to [`return`][return] one or more values as a result of some operation(s), or it may be used for one or more [`side effects`][side effects].
8
-
If a function does not specify a return value it will still return `None`.
8
+
If a function does not specify a return value it will still return `None`.
9
9
10
10
Following is an example of a function with a side effect:
11
11
12
12
```python
13
13
>>>defhello():
14
-
...print("Hello")
14
+
...print("Hello")
15
15
...
16
16
>>> hello()
17
17
Hello
@@ -28,8 +28,8 @@ The argument is used by the `print` function to know what to print.
28
28
Note that the body of the function is indented.
29
29
The indentation is important because Python relies on it to know where that block of code ends.
30
30
The function body ends at either the end of the program or just before the next line of code that is _not_ indented.
31
-
Since `hello()` does not specify a `return` value, it executes its side effect - which is calling `print()` -- and then returns `None`.
32
-
Finally, we call the function by using its name and the parentheses - which signals to the Python interpreter that this is a _callable_ name.
31
+
Since `hello()` does not specify a `return` value, it executes its side effect — which is calling `print()`— and then returns `None`.
32
+
Finally, we call the function by using its name and the parentheses — which signals to the Python interpreter that this is a _callable_ name.
33
33
34
34
Following is an example of a function with a return value:
35
35
@@ -61,7 +61,7 @@ Following is an example of a function which accepts an argument:
If we don't want the program to error with no argument (_but want to allow the calling code to not supply one_), we can define a [default argument][default arguments].
85
87
A default argument defines what value to use if the argument is missing when the function is called.
86
88
@@ -92,7 +94,6 @@ Following is an example of a function with a default argument:
92
94
...
93
95
>>>print(hello())
94
96
Hello, you
95
-
96
97
```
97
98
98
99
The `name` parameter is given the default argument of `"you"`, so the program outputs `Hello, you`, if not passed a `name` argument.
@@ -103,7 +104,8 @@ For more about function arguments, please see the [function arguments][function
0 commit comments