diff --git a/snippets/byte_size.md b/snippets/byte_size.md index 3d992cce5..d3f955048 100644 --- a/snippets/byte_size.md +++ b/snippets/byte_size.md @@ -7,7 +7,7 @@ lastUpdated: 2020-11-02T19:27:07+02:00 Returns the length of a string in bytes. -- Use `str.encode('utf-8')` to encode the given string and return its length. +- Use `str.encode()` to encode the given string and return its length. ```py def byte_size(s): diff --git a/snippets/daterange.md b/snippets/daterange.md index 994e0f88a..ac411397e 100644 --- a/snippets/daterange.md +++ b/snippets/daterange.md @@ -9,7 +9,7 @@ Creates a list of dates between `start` (inclusive) and `end` (not inclusive). - Use `datetime.timedelta.days` to get the days between `start` and `end`. - Use `int()` to convert the result to an integer and `range()` to iterate over each day. -- Use a list comprehension and `datetime.timedelta()` to create a list of `datetime.date` objects. +- Use a list comprehension and `datetime.timedelta` to create a list of `datetime.date` objects. ```py from datetime import timedelta, date diff --git a/snippets/fahrenheit_to_celsius.md b/snippets/fahrenheit_to_celsius.md index a37f63340..75dde9323 100644 --- a/snippets/fahrenheit_to_celsius.md +++ b/snippets/fahrenheit_to_celsius.md @@ -8,11 +8,11 @@ lastUpdated: 2021-01-04T12:47:04+02:00 Converts Fahrenheit to Celsius. -- Follow the conversion formula `C = (F - 32) * 5/9`. +- Follow the conversion formula `C = (F - 32) * 5 / 9`. ```py def fahrenheit_to_celsius(degrees): - return ((degrees - 32) * 5/9) + return ((degrees - 32) * 5 / 9) ``` ```py diff --git a/snippets/frequencies.md b/snippets/frequencies.md index 0922c9210..6e7ba3497 100644 --- a/snippets/frequencies.md +++ b/snippets/frequencies.md @@ -7,7 +7,7 @@ lastUpdated: 2020-11-02T19:27:53+02:00 Creates a dictionary with the unique values of a list as keys and their frequencies as the values. -- Use `collections.defaultdict()` to store the frequencies of each unique element. +- Use `collections.defaultdict` to store the frequencies of each unique element. - Use `dict()` to return a dictionary with the unique elements of the list as keys and their frequencies as the values. ```py diff --git a/snippets/lcm.md b/snippets/lcm.md index 1817eb26f..7dce5229b 100644 --- a/snippets/lcm.md +++ b/snippets/lcm.md @@ -1,13 +1,13 @@ --- -title: lcm -tags: math,list,intermediate +title: lcm +tags: math,list,intermediate firstSeen: 2018-01-08T22:30:17+02:00 lastUpdated: 2020-11-02T19:31:15+02:00 --- Returns the least common multiple of a list of numbers. -- Use `functools.reduce()`, `math.gcd()` and `lcm(x,y) = x * y / gcd(x,y)` over the given list. +- Use `functools.reduce()`, `math.gcd()` and `lcm(x, y) = x * y / gcd(x, y)` over the given list. ```py from functools import reduce diff --git a/snippets/when.md b/snippets/when.md index 93869d6b0..17fc3cbcb 100644 --- a/snippets/when.md +++ b/snippets/when.md @@ -5,9 +5,9 @@ firstSeen: 2020-01-02T20:25:45+02:00 lastUpdated: 2020-11-09T23:56:11+02:00 --- -Tests a value, `x`, against a testing function, conditionally applying a function. +Tests a value, `x`, against a testing function, conditionally applying a function. -- Check if the value of `predicate(x)` is `True` and if so return `when_true(x)`, otherwise return `x`. +- Check if the value of `predicate()` is `True` for `x` and if so call `when_true()`, otherwise return `x`. ```py def when(predicate, when_true):