Skip to content

Commit 5bb5867

Browse files
Format using Prettier (exercism#1253)
[Docs] Format using Prettier
1 parent ffb2b6c commit 5bb5867

28 files changed

+81
-90
lines changed

exercises/concept/strings/.docs/hints.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,23 @@
44

55
### 1. Get message from a log line
66

7-
- Strings in Python have [lots of convenient instance methods][str-type-methods] for cleaning, splitting, manipulating, and creating new strings. Extracting values from a string could be done by splitting it based on a substring, for example.
7+
- Strings in Python have [lots of convenient instance methods][str-type-methods] for cleaning, splitting, manipulating, and creating new strings. Extracting values from a string could be done by splitting it based on a substring, for example.
88

99
### 2. Get log level from a log line
1010

11-
- Strings also have methods that help convert letters from lower to uppercase and vice-versa.
11+
- Strings also have methods that help convert letters from lower to uppercase and vice-versa.
1212

1313
### 3. Reformat a log line
1414

1515
Strings are immutable, but can be combined together to make new strings, or have elements replaced. This goal can be accomplished by using string methods, or operators like `+` or `+=` (which are overloaded to work with strings).
1616
Python also has a concept of string formatting, like many other languages.
1717

18-
- The [`str.join()`][str-join] method is useful to join an iterable of strings into one string by interspersing them with a common value, e.g. `":".join("abcde")` would create `"a:b:c:d:e"`.
19-
- [`str.format()`][str-format] is an idiomatic way to do string interpolation in Python (inserting one or more string value(s) into another).
20-
- [Format strings][format-str] are another convenient way to interpolate values into a string. This strategy is particularly useful when more than one named variable needs to be inserted into a final output.
18+
- The [`str.join()`][str-join] method is useful to join an iterable of strings into one string by interspersing them with a common value, e.g. `":".join("abcde")` would create `"a:b:c:d:e"`.
19+
- [`str.format()`][str-format] is an idiomatic way to do string interpolation in Python (inserting one or more string value(s) into another).
20+
- [Format strings][format-str] are another convenient way to interpolate values into a string. This strategy is particularly useful when more than one named variable needs to be inserted into a final output.
2121

22-
[python-str-doc]: https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str
23-
[str-type-methods]: https://docs.python.org/3/library/stdtypes.html#str
24-
[str-join]: https://docs.python.org/3/library/stdtypes.html#str.join
25-
[str-format]: https://docs.python.org/3/library/stdtypes.html#str.format
26-
[format-str]: https://docs.python.org/3/library/string.html#formatstrings
22+
[python-str-doc]: https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str
23+
[str-type-methods]: https://docs.python.org/3/library/stdtypes.html#str
24+
[str-join]: https://docs.python.org/3/library/stdtypes.html#str.join
25+
[str-format]: https://docs.python.org/3/library/stdtypes.html#str.format
26+
[format-str]: https://docs.python.org/3/library/string.html#formatstrings

exercises/concept/strings/.meta/design.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ The goal of this exercise is to teach the student about Python strings, and fami
66

77
## Things to teach
88

9-
- Know that Python has a `str` type.
10-
- Know how to find items in a string.
11-
- Know how to manipulate strings to create new strings.
12-
- Familiarize one's self with string instance methods in Python.
13-
- Learn about string formatting.
9+
- Know that Python has a `str` type.
10+
- Know how to find items in a string.
11+
- Know how to manipulate strings to create new strings.
12+
- Familiarize one's self with string instance methods in Python.
13+
- Learn about string formatting.
1414

1515
## Things not to teach
1616

@@ -21,11 +21,11 @@ The goal of this exercise is to teach the student about Python strings, and fami
2121

2222
The Concepts this exercise unlocks are:
2323

24-
- `strings-basic`: know about `str` type in Python, know some basic methods, know about formatting.
24+
- `strings-basic`: know about `str` type in Python, know some basic methods, know about formatting.
2525

2626
## Prerequisites
2727

28-
- `functions`: The student should be familiar with creating functions.
28+
- `functions`: The student should be familiar with creating functions.
2929

3030
## Representer
3131

reference/concepts/argument_unpacking.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@
33
TODO: ADD MORE
44

55
- the example solution for this exercise uses `splat` (`*`) to unpack rows for the `zip()` function. [matrix](../exercise-concepts/matrix.md)
6-

reference/concepts/assignment.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,3 @@ TODO: ADD MORE
55
- The example solution uses assignment for variables and other values. [markdown](../exercise-concepts/markdown.md)
66
- instance properties need to be assigned passed in data [matrix](../exercise-concepts/matrix.md)
77
- the example uses assignment for all the instance properties and `instructions` dictionary. [robot-simulator](../exercise-concepts/robot-simulator.md)
8-

reference/concepts/builtin_functions/len.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,3 @@ See [docs][docs].
99
[docs]: https://docs.python.org/3/library/functions.html#len
1010
[hamming]: ../../exercise-concepts/hamming.md
1111
[variable-length-quantity]: ../../exercise-concepts/variable-length-quantity.md
12-

reference/concepts/builtin_functions/zip.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,3 @@ See [docs][docs].
99
[docs]: https://docs.python.org/3/library/functions.html#zip
1010
[hamming]: ../../exercise-concepts/hamming.md
1111
[matrix]: ../../exercise-concepts/matrix.md
12-

reference/concepts/builtin_types/bytearray.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ TODO: ADD MORE DETAIL
55
See the Python documentation entries for the [binary sequence types][docs-binary-sequence-types], of which [`bytearray`][docs-bytearray-type] is the [mutable][mutation] member. You'll also want to familiarize yourself with the use of [`bytearray` as a casting function][docs-bytearray-as-function], as well as the many [common binary sequence methods][docs-binary-sequence-methods] and [mutable sequence methods][docs-mutable-sequence-methods] available to use on the type.
66

77
[mutation]: ../../../../../reference/concepts/mutation.md
8-
98
[docs-binary-sequence-types]: https://docs.python.org/3/library/stdtypes.html#binaryseq
109
[docs-bytearray-type]: https://docs.python.org/3/library/stdtypes.html#typebytearray
1110
[docs-bytearray-as-function]: https://docs.python.org/3/library/stdtypes.html#bytearray

reference/concepts/builtin_types/frozenset.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
TODO: ADD MORE DETAIL
44

5-
See the Python documentation entries for the [`set`][docs-set] collection, the [immutable] [set type][docs-set-type]; essentially a [hash map][hash-map] in which only the key is relevant, and which disallows [mutaion][mutation] of keys after intialization.
5+
See the Python documentation entries for the [`set`][docs-set] collection, the [immutable][set type][docs-set-type]; essentially a [hash map][hash-map] in which only the key is relevant, and which disallows [mutaion][mutation] of keys after intialization.
66

77
[immutable]: ../../../../../reference/concepts/immutability.md
88
[mutation]: ../../../../../reference/concepts/mutation.md

reference/concepts/builtin_types/list.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# `list`
22

3-
Lists are dynamic arrays that can be resized by Python at runtime. They are homogenous, meaning they are able to hold any data type, including other lists, and can even contain themselves (recursive data structures are relatively simple in Python).
3+
Lists are dynamic arrays that can be resized by Python at runtime. They are homogenous, meaning they are able to hold any data type, including other lists, and can even contain themselves (recursive data structures are relatively simple in Python).
44

55
Simple flat lists are used extensively in [variable-length-quantity][variable-length-quantity], [markdown][markdown], and [robot-simulator][robot-simulator].
66

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# `range`
22

3-
The `range()` built-in represents an immutable sequence of numbers (or any object that implements the __index__ dunder method). Used in the [markdown][markdown] to control the number of loops while iterating through a passed-in line or list. Used in [robot-simulator][robot-simulator] to represent the values from zero to 3 as assigned to NORTH, EAST, SOUTH, WEST.
3+
The `range()` built-in represents an immutable sequence of numbers (or any object that implements the **index** dunder method). Used in the [markdown][markdown] to control the number of loops while iterating through a passed-in line or list. Used in [robot-simulator][robot-simulator] to represent the values from zero to 3 as assigned to NORTH, EAST, SOUTH, WEST.
44

55
TODO: ADD MORE DETAIL
66

@@ -10,6 +10,5 @@ See the Python documentation entries for the [immutable][immutable] [`range` typ
1010
[docs-range-type]: https://docs.python.org/3/library/stdtypes.html#typesseq-range
1111
[docs-range-as-function]: https://docs.python.org/3/library/stdtypes.html#range
1212
[docs-sequence-types]: https://docs.python.org/3/library/stdtypes.html#typesseq
13-
1413
[markdown]: ../../exercise-concepts/markdown.md
1514
[robot-simulator]: ../../exercise-concepts/robot-simulator.md

reference/concepts/builtin_types/str.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Python's [string][general-concept-string] type, which always holds encoded [Unic
44

55
A useful concept to know to solve the [hamming][hamming] exercise.
66

7-
TODO: ADD MORE DETAIL
7+
TODO: ADD MORE DETAIL
88

99
See the Python documentation entries for the [immutable][immutability] [text sequence type][docs-text-sequence-type]. You'll also want to familiarize yourself with the use of [`str` as a casting function][docs-str-as-function], as well as the many [string methods][docs-string-methods] available to use on the type.
1010

reference/concepts/dunder_methods.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ TODO: ADD MORE
66
- student needs to know when to use dunder methods `__init__` and `__str__` [binary-search-tree](../exercise-concepts/binary-search-tree.md)
77
- "dunder" -> "double under", referring to the names of these methods being prefixed with two underscores, e.g. `__init__`. There is no formal privacy in Python, but conventionally a single underscore indicates a private method, or one that the programmer should assume may change at any time; methods without an underscore are considered part of an object's public API. Double underscores are even more special - they are used by Python's builtin functions like `len()`, for example, to allow objects to implement various interfaces and functionality. They can also be used for operator overloading. If you have a custom class that you would like to be able to compare to other instances of the same class, implementing `__lt__`, `__gt__`, `__eq__` etc. allow programmers to use the `>`, `<`, `=` operators. Dunder methods allow programmers to build useful objects with simple interfaces, i.e. you can add two instances together using `+` instead of writing something like `instance1.add(instance2)`. [hamming](../exercise-concepts/hamming.md)
88
- the example uses the `__init__` magic method as its constructor for the class [matrix](../exercise-concepts/matrix.md)
9-
- User defined classes can (and generally do) overload the `__init__` method, whose first argument is `self`, because the result of `__init__` is a class *instance*. [phone-number](../exercise-concepts/phone-number.md)
9+
- User defined classes can (and generally do) overload the `__init__` method, whose first argument is `self`, because the result of `__init__` is a class _instance_. [phone-number](../exercise-concepts/phone-number.md)
1010
- The example uses `__init__` as a constructor for the class, which also calls `__new__`. In addition, the example uses `__call__()` via the appending of `()` to instance method names, and `__eq__()` (_rich compairison_) via the use of `==` [robot-simulator](../exercise-concepts/robot-simulator.md)

reference/concepts/equality_operator.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
TODO: ADD MORE
44

5-
- the `==` operator calls the dunder method `__eq__()`. By default, objects of different types are never considered equal to each other unless they are numerical types (ie int, float) or have otherwise overloaded the default implementation of the `__eq__` dunder method. `==` is always defined, but for some object types (_like class objects_) it is equivalent to calling `is`. See [`__eq__`](https: //docs.python.org/3/reference/datamodel.html#object.__eq__) for additional details. This exercise uses the equality operator to test that the `self.direction` attribute is equal to one of the constant values defined. [robot-simulator](../exercise-concepts/robot-simulator.md)
5+
- the `==` operator calls the dunder method `__eq__()`. By default, objects of different types are never considered equal to each other unless they are numerical types (ie int, float) or have otherwise overloaded the default implementation of the `__eq__` dunder method. `==` is always defined, but for some object types (_like class objects_) it is equivalent to calling `is`. See [`__eq__`](https: //docs.python.org/3/reference/datamodel.html#object.**eq**) for additional details. This exercise uses the equality operator to test that the `self.direction` attribute is equal to one of the constant values defined. [robot-simulator](../exercise-concepts/robot-simulator.md)

reference/concepts/instance_methods.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ TODO: ADD MORE
44

55
- the exercise relies on the `def` statement to create an instance method [allergies](../exercise-concepts/allergies.md)
66
- use of `def` to define a class's methods [clock](../exercise-concepts/clock.md)
7-
- classes can have instance *methods* which are called from an instance of the class (as opposed to class methods, called from the Class itself). The first parameter of an instance method is always `self`, which is provided when calling from the instance (i.e. the programmer does not need to pass it as an argument explicitly). Static methods are methods called from the class itself, and are not connected to an instance of the class. They have access to class attributes (those defined on the class, not connected to the `self`), and do not require an instance of the class to exist. Classes can also define a `property` by using the `@property` decorator (not shown here); a `property` can be "lazily evaluated" to avoid uneeded computation [phone-number](../exercise-concepts/phone-number.md)
7+
- classes can have instance _methods_ which are called from an instance of the class (as opposed to class methods, called from the Class itself). The first parameter of an instance method is always `self`, which is provided when calling from the instance (i.e. the programmer does not need to pass it as an argument explicitly). Static methods are methods called from the class itself, and are not connected to an instance of the class. They have access to class attributes (those defined on the class, not connected to the `self`), and do not require an instance of the class to exist. Classes can also define a `property` by using the `@property` decorator (not shown here); a `property` can be "lazily evaluated" to avoid uneeded computation [phone-number](../exercise-concepts/phone-number.md)
88
- tests for this exercises require one or more instance methods that will return a specified row or column list of the `matrix`. [matrix](../exercise-concepts/matrix.md)
99
- tests for this exercises require one or more instance methods that will take in a set of starting coordinates and a bearing and then accept a series of instructions that "move" the instance to a new set of coordinates and bearing. [robot-simulator](../exercise-concepts/robot-simulator.md)

reference/concepts/iterables.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ TODO: ADD MORE
44

55
- strings are iterable, which provides a lot of opportunity to leverage Python functions against them [hamming](../exercise-concepts/hamming.md)
66
- understanding that strings, lists, and other data structures can be iterated over in the same fashion [matrix](../exercise-concepts/matrix.md)
7-
- characters in a string are *iterables* and are subject to index and slice access as described below [phone-number](../exercise-concepts/phone-number.md)
7+
- characters in a string are _iterables_ and are subject to index and slice access as described below [phone-number](../exercise-concepts/phone-number.md)
88
- The example solution uses the `for _ in _` syntax to iterate over a list of lines. This is possible because a list is an `iterable`. [markdown](../exercise-concepts/markdown.md)

reference/concepts/pep_8_style_guide.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# PEP 8 Style
22

3-
Unlike most earlier languages -- and many newer -- Python has an "official" style guide, and has had one for quite some time.
3+
Unlike most earlier languages -- and many newer -- Python has an "official" style guide, and has had one for quite some time.
44

55
> One of [Python creator Guido von Rossum]'s key insights is that code is read much more often than it is written. The guidelines provided here are intended to improve the readability of code and make it consistent across the wide spectrum of Python code. As [PEP 20](zen_of_python.md) says, "Readability counts".
66

reference/concepts/star_args.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# `*args` for variadic arguments
22

3-
TODO: Explain the use of ``*args` for collecting up an unknown number of positional arguments in function signatures.
3+
TODO: Explain the use of `*args` for collecting up an unknown number of positional arguments in function signatures.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# `**kwargs` for variadic keyword arguments
22

3-
TODO: Explain the use of ``**kwargs` for collecting up a variable number of keyword arguments in function signatures.
3+
TODO: Explain the use of `**kwargs` for collecting up a variable number of keyword arguments in function signatures.

reference/concepts/zen_of_python.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ The _Zen of Python_ by Tim Peters, and also known as [PEP-20](https://www.python
1717
- There should be one-- and preferably only one --obvious way to do it.
1818
- Although that way may not be obvious at first unless you're Dutch.
1919
- Now is better than never.
20-
- Although never is often better than *right* now.
20+
- Although never is often better than _right_ now.
2121
- If the implementation is hard to explain, it's a bad idea.
2222
- If the implementation is easy to explain, it may be a good idea.
2323
- Namespaces are one honking great idea -- let's do more of those!

reference/exercise-concepts/allergies.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,3 @@ There are also various solutions involving lists, but these all come with O(N) l
7878
- [Property Decorator][property-decorator]: this exercise relies on the `@property` decorator to provide read-only dynamic access to the current list of allergens
7979
- [Membership Testing][membership-testing]: this exercise relies on testing membership of a value in a collection of values
8080
- [Lookup Efficiency][lookup-efficiency]: an efficient solution requires knowing that membership testing is O(1) in **dict** and the **enum.Enum** variants, but is O(N) in **list** and other sequential types
81-

reference/exercise-concepts/binary-search-tree.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,3 @@ class BinarySearchTree:
8080
- [Lists][lists]: knowledge of lists and iteration on lists is required for this exercise
8181
- [Conditional structures][conditional-structures]: knowledge of conditional conceptis and `if...else` statements are required
8282
- [Methods of list][methods-of-list]: the use of methods of list could be useful in this exercise. Methods like `append`, `pop`...
83-

0 commit comments

Comments
 (0)