mirror of
https://github.com/TheAlgorithms/Python.git
synced 2026-03-13 09:50:19 +08:00
refactor: Indent ... for visual purposes (#7744)
This commit is contained in:
committed by
GitHub
parent
e8915097c4
commit
9bba42eca8
@@ -32,7 +32,7 @@ def bisection(a: float, b: float) -> float:
|
||||
3.158203125
|
||||
>>> bisection(2, 3)
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
...
|
||||
ValueError: Wrong space!
|
||||
"""
|
||||
# Bolzano theory in order to find if there is a root between a and b
|
||||
|
||||
@@ -18,15 +18,15 @@ def catalan(number: int) -> int:
|
||||
14
|
||||
>>> catalan(0)
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
...
|
||||
ValueError: Input value of [number=0] must be > 0
|
||||
>>> catalan(-1)
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
...
|
||||
ValueError: Input value of [number=-1] must be > 0
|
||||
>>> catalan(5.0)
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
...
|
||||
TypeError: Input value of [number=5.0] must be an integer
|
||||
"""
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ def fib_iterative(n: int) -> list[int]:
|
||||
[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55]
|
||||
>>> fib_iterative(-1)
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
...
|
||||
Exception: n is negative
|
||||
"""
|
||||
if n < 0:
|
||||
@@ -73,7 +73,7 @@ def fib_recursive(n: int) -> list[int]:
|
||||
[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55]
|
||||
>>> fib_iterative(-1)
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
...
|
||||
Exception: n is negative
|
||||
"""
|
||||
|
||||
@@ -105,7 +105,7 @@ def fib_memoization(n: int) -> list[int]:
|
||||
[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55]
|
||||
>>> fib_iterative(-1)
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
...
|
||||
Exception: n is negative
|
||||
"""
|
||||
if n < 0:
|
||||
@@ -146,11 +146,11 @@ def fib_binet(n: int) -> list[int]:
|
||||
[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55]
|
||||
>>> fib_binet(-1)
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
...
|
||||
Exception: n is negative
|
||||
>>> fib_binet(1475)
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
...
|
||||
Exception: n is too large
|
||||
"""
|
||||
if n < 0:
|
||||
|
||||
@@ -26,19 +26,19 @@ def maclaurin_sin(theta: float, accuracy: int = 30) -> float:
|
||||
0.5440211108893703
|
||||
>>> maclaurin_sin("10")
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
...
|
||||
ValueError: maclaurin_sin() requires either an int or float for theta
|
||||
>>> maclaurin_sin(10, -30)
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
...
|
||||
ValueError: maclaurin_sin() requires a positive int for accuracy
|
||||
>>> maclaurin_sin(10, 30.5)
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
...
|
||||
ValueError: maclaurin_sin() requires a positive int for accuracy
|
||||
>>> maclaurin_sin(10, "30")
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
...
|
||||
ValueError: maclaurin_sin() requires a positive int for accuracy
|
||||
"""
|
||||
|
||||
@@ -78,19 +78,19 @@ def maclaurin_cos(theta: float, accuracy: int = 30) -> float:
|
||||
-0.8390715290764521
|
||||
>>> maclaurin_cos("10")
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
...
|
||||
ValueError: maclaurin_cos() requires either an int or float for theta
|
||||
>>> maclaurin_cos(10, -30)
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
...
|
||||
ValueError: maclaurin_cos() requires a positive int for accuracy
|
||||
>>> maclaurin_cos(10, 30.5)
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
...
|
||||
ValueError: maclaurin_cos() requires a positive int for accuracy
|
||||
>>> maclaurin_cos(10, "30")
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
...
|
||||
ValueError: maclaurin_cos() requires a positive int for accuracy
|
||||
"""
|
||||
|
||||
|
||||
@@ -16,15 +16,15 @@ def proth(number: int) -> int:
|
||||
25
|
||||
>>> proth(0)
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
...
|
||||
ValueError: Input value of [number=0] must be > 0
|
||||
>>> proth(-1)
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
...
|
||||
ValueError: Input value of [number=-1] must be > 0
|
||||
>>> proth(6.0)
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
...
|
||||
TypeError: Input value of [number=6.0] must be an integer
|
||||
"""
|
||||
|
||||
|
||||
@@ -18,12 +18,12 @@ def sylvester(number: int) -> int:
|
||||
|
||||
>>> sylvester(-1)
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
...
|
||||
ValueError: The input value of [n=-1] has to be > 0
|
||||
|
||||
>>> sylvester(8.0)
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
...
|
||||
AssertionError: The input value of [n=8.0] is not an integer
|
||||
"""
|
||||
assert isinstance(number, int), f"The input value of [n={number}] is not an integer"
|
||||
|
||||
@@ -14,11 +14,11 @@ def zeller(date_input: str) -> str:
|
||||
Validate out of range month
|
||||
>>> zeller('13-31-2010')
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
...
|
||||
ValueError: Month must be between 1 - 12
|
||||
>>> zeller('.2-31-2010')
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
...
|
||||
ValueError: invalid literal for int() with base 10: '.2'
|
||||
|
||||
Validate out of range date:
|
||||
|
||||
Reference in New Issue
Block a user