Update formatting

This commit is contained in:
Isabelle Viktoria Maciohsek
2022-01-30 19:18:14 +02:00
parent c95f39e4ba
commit 2a16eb9892
6 changed files with 10 additions and 10 deletions

View File

@ -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):

View File

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

View File

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

View File

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

View File

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

View File

@ -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):