Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion concepts/binary-octal-hexadecimal/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ As with binary and octal, giving the wrong base will raise a `ValueError`.


[binary]: https://en.wikipedia.org/wiki/Binary_number
[bit_count]: https://docs.python.org/3/library/stdtypes.html#int.bit_count
[bit_count]: https://docs.python.org/3/library/stdtypes.html#int.bit_count
[bit_length]: https://docs.python.org/3/library/stdtypes.html#int.bit_length
[hexadecimal]: https://en.wikipedia.org/wiki/Hexadecimal
[numeral-systems]: https://en.wikipedia.org/wiki/Numeral_system
Expand Down
8 changes: 4 additions & 4 deletions concepts/classes/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

`Classes` combine data with behavior.
Classes are used to create copies or `instances` of bundled data and behavior, commonly known as `objects`.
Objects can represent real world entities (_such as cars or cats_) - or more abstract concepts (_such as integers, vehicles, or mammals_).
Objects can represent real world entities (_such as cars or cats_) or more abstract concepts (_such as integers, vehicles, or mammals_).
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.

## Classes
Expand Down Expand Up @@ -41,7 +41,7 @@ An instance (_object_) of `MyClass` can be created and bound to a name:
<__main__.MyClass at 0x15adc55b0>
```

`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:
`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:

```python
>>> new_object = MyClass()
Expand All @@ -66,7 +66,7 @@ True
```

Class attributes are defined in the body of the class itself, before any other methods.
They are owned by the class - allowing them to be shared across instances.
They are owned by the class allowing them to be shared across instances.
Because these attributes are shared by all instances of the class, their value can be accessed and manipulated from the class directly.
Altering the value of class attributes alters the value _**for all objects instantiated from the class**_:

Expand Down Expand Up @@ -289,7 +289,7 @@ class MyClass:

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.

The `pass` keyword is a syntactically valid placeholder - it prevents Python from throwing a syntax error for an empty function or class definition.
The `pass` keyword is a syntactically valid placeholder it prevents Python from throwing a syntax error for an empty function or class definition.
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.'

```python
Expand Down
2 changes: 1 addition & 1 deletion concepts/classes/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Classes are definitions combining data (_otherwise known as `attributes`, `properties`,`data members`, `variables`, or `fields`_) with `functions` (_otherwise known as `methods`_).
Class definitions are used to create copies or `instances` of the `class`, commonly known as `objects`.
Objects can represent real world entities (_such as cars or cats_) - or more abstract concepts (_such as integers, vehicles, or mammals_).
Objects can represent real world entities (_such as cars or cats_) or more abstract concepts (_such as integers, vehicles, or mammals_).
Each object is unique in computer memory and represents some part of an overall model.
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.

Expand Down
6 changes: 3 additions & 3 deletions concepts/comparisons/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ False

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`_).
If all code points in both strings match and are _**in the same order**_, the two strings are considered equal.
This comparison is done in a 'pair-wise' fashion - first-to-first, second-to-second, etc.
This comparison is done in a 'pair-wise' fashion first-to-first, second-to-second, etc.
In Python 3.x, `str` and `bytes` cannot be directly coerced/compared.

```python
Expand Down Expand Up @@ -116,7 +116,7 @@ False

## Comparing Container Data Types

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.
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.

```python
>>> [1, 2] == [1, 2]
Expand Down Expand Up @@ -148,7 +148,7 @@ Comparison operators can be chained _arbitrarily_.
Note that the evaluation of an expression takes place from `left` to `right`.
For example, `x < y <= z` is equivalent to `x < y and y <= z`, except that `y` is evaluated **only once**.
In both cases, `z` is _not_ evaluated **at all** when `x < y` is found to be `False`.
This is often called `short-circuit evaluation` - the evaluation stops if the truth value of the expression has already been determined.
This is often called `short-circuit evaluation` the evaluation stops if the truth value of the expression has already been determined.

`Short circuiting` is supported by various boolean operators, functions, and also by comparison chaining in Python.
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.
Expand Down
7 changes: 4 additions & 3 deletions concepts/complex-numbers/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ ValueError: complex() arg is a malformed string
>>> z2
(2+1.5j)
```

The end result is identical to using the `complex()` constructor.


Expand Down Expand Up @@ -98,6 +99,7 @@ However, it is still a complex number in Python:
You may have heard that "`i` (or `j`) is the square root of -1".

For now, all this means is that the imaginary part _by definition_ satisfies the equality

```python
1j * 1j == -1 # => True
```
Expand Down Expand Up @@ -148,7 +150,7 @@ Integer division is ___not___ possible on complex numbers, so the `//` and `%` o

There are two functions implemented for numeric types that are very useful when working with complex numbers:

- `<complex number>.conjugate()` simply flips the sign of the imaginary part of a complex number (_from + to - or vice-versa_).
- `<complex number>.conjugate()` simply flips the sign of the imaginary part of a complex number (_from `+` to `-` or vice-versa_).
- Because of the way complex multiplication works, this is more useful than you might think.
- `abs(<complex number>)` is guaranteed to return a real number with no imaginary part.

Expand Down Expand Up @@ -212,7 +214,7 @@ It was strange and new in the 16th century.
### Why would anyone use these?

It turns out that complex numbers are the simplest way to describe anything that rotates or anything with a wave-like property.
So they are used widely in electrical engineering, audio processing, physics, computer gaming, and navigation - to name only a few applications.
So they are used widely in electrical engineering, audio processing, physics, computer gaming, and navigation to name only a few applications.

You can see things rotate.
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.
Expand Down Expand Up @@ -257,4 +259,3 @@ So, you are probably using technology that relies on complex number calculations
[engineering-complex]: https://www.khanacademy.org/science/electrical-engineering/ee-circuit-analysis-topic/ee-ac-analysis/v/ee-complex-numbers
[ints]: https://docs.python.org/3/library/functions.html#int
[floats]: https://docs.python.org/3/library/functions.html#float

5 changes: 3 additions & 2 deletions concepts/decorators/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,11 @@ function3 = decorator_with_default_arg()(function3)

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.

Decorators are functions which take at least one argument - the function which they are wrapping.
Decorators are functions which take at least one argument the function which they are wrapping.
They usually return either the wrapped function or the result of an expression that uses the wrapped function.

A simple decorator - one that simply returns its wrapped function - can be written as follows:
A simple decorator — one that simply returns its wrapped function — can be written as follows:

```python
>>> def do_nothing(func):
... return func
Expand Down
2 changes: 1 addition & 1 deletion concepts/dict-methods/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

The `dict` class in Python provides many useful [methods][dict-methods] for working with dictionaries.
Some were introduced in the concept for `dict`s.
Here we cover a few more - along with some techniques for iterating through and manipulating dictionaries.
Here we cover a few more along with some techniques for iterating through and manipulating dictionaries.

- `<dict>.setdefault()` automatically adds keys without throwing a KeyError.
- `<dict>.fromkeys(<iterable>, <default value>)` creates a new `dict` from any number of iterables.
Expand Down
16 changes: 9 additions & 7 deletions concepts/functions/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ Functions are used to perform specific and repetitive tasks.

More formally: a function is any Python object to which the [`function call`][calls] operation can be applied.
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].
If a function does not specify a return value it will still return `None`.
If a function does not specify a return value it will still return `None`.

Following is an example of a function with a side effect:

```python
>>> def hello():
... print("Hello")
... print("Hello")
...
>>> hello()
Hello
Expand All @@ -28,8 +28,8 @@ The argument is used by the `print` function to know what to print.
Note that the body of the function is indented.
The indentation is important because Python relies on it to know where that block of code ends.
The function body ends at either the end of the program or just before the next line of code that is _not_ indented.
Since `hello()` does not specify a `return` value, it executes its side effect - which is calling `print()` -- and then returns `None`.
Finally, we call the function by using its name and the parentheses - which signals to the Python interpreter that this is a _callable_ name.
Since `hello()` does not specify a `return` value, it executes its side effect which is calling `print()` and then returns `None`.
Finally, we call the function by using its name and the parentheses which signals to the Python interpreter that this is a _callable_ name.

Following is an example of a function with a return value:

Expand Down Expand Up @@ -61,7 +61,7 @@ Following is an example of a function which accepts an argument:
>>> def hello(name):
... return f"Hello, {name}"
...
>>>print(hello("Bob"))
>>> print(hello("Bob"))
Hello, Bob

```
Expand All @@ -81,6 +81,8 @@ Traceback (most recent call last):
print(hello())

TypeError: hello() missing 1 required positional argument: 'name'
```

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].
A default argument defines what value to use if the argument is missing when the function is called.

Expand All @@ -92,7 +94,6 @@ Following is an example of a function with a default argument:
...
>>> print(hello())
Hello, you

```

The `name` parameter is given the default argument of `"you"`, so the program outputs `Hello, you`, if not passed a `name` argument.
Expand All @@ -103,7 +104,8 @@ For more about function arguments, please see the [function arguments][function
[arguments]: https://www.w3schools.com/python/gloss_python_function_arguments.asp
[calls]: https://docs.python.org/3/reference/expressions.html#calls
[def]: https://www.geeksforgeeks.org/python-def-keyword/
[function arguments]: ../function-arguments/about.md
[default arguments]: https://www.geeksforgeeks.org/default-arguments-in-python/
[function arguments]: https://exercism.org/tracks/python/concepts/function-arguments
[function]: https://docs.python.org/3/glossary.html#term-function
[parameters]: https://www.codecademy.com/learn/flask-introduction-to-python/modules/learn-python3-functions/cheatsheet
[return]: https://www.geeksforgeeks.org/python-return-statement/
Expand Down
4 changes: 2 additions & 2 deletions concepts/generators/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ A `generator` is a function or expression that returns a special type of [iterat

A generator function looks like any other function, but contains one or more [yield expressions][yield expression].
Each `yield` will suspend code execution, saving the current execution state (_including all local variables and try-statements_).
When the generator resumes, it picks up state from the suspension - unlike regular functions which reset with every call.
When the generator resumes, it picks up state from the suspension unlike regular functions which reset with every call.


## Constructing a generator
Expand Down Expand Up @@ -55,7 +55,7 @@ Generator-iterators and the iterators returned by common Python [`iterables`][it
- They are not sequence types, and _do not_ have `indexes`.
You cannot reference a previous or future value using addition or subtraction and you cannot use bracket (`[]`) notation or slicing.
- They cannot be used with the `len()` function, as they have no length.
- They can be _finite_ or _infinite_ - be careful when collecting all values from an _infinite_ `generator-iterator`!
- They can be _finite_ or _infinite_ be careful when collecting all values from an _infinite_ `generator-iterator`!

[iterator]: https://docs.python.org/3.11/glossary.html#term-iterator
[iterables]: https://wiki.python.org/moin/Iterator
Expand Down
2 changes: 1 addition & 1 deletion concepts/generators/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ A generator in Python is a _callable function_ or expression that returns a spec

A generator function looks like any other function, but contains one or more [yield expressions][yield expression].
Each `yield` will suspend code execution, saving the current execution state (_including all local variables and try-statements_).
When the generator function resumes, it picks up state from the suspension - unlike regular functions which reset with every call.
When the generator function resumes, it picks up state from the suspension unlike regular functions which reset with every call.

[lazy iterator]: https://en.wikipedia.org/wiki/Lazy_evaluation
[iterator]: https://docs.python.org/3.11/glossary.html#term-iterator
Expand Down
Loading
Loading