mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-11-27 15:01:08 +00:00
[mypy] Fix type annotations for maths (#4617)
* Fix mypy errors for armstrong_numbers.py * Fix mypy errors for harmonic_series.py * Fix mypy errors for average_median.py
This commit is contained in:
parent
4545270ace
commit
af0810fca1
|
@ -9,7 +9,7 @@ Armstrong numbers are also called Narcissistic numbers and Pluperfect numbers.
|
|||
On-Line Encyclopedia of Integer Sequences entry: https://oeis.org/A005188
|
||||
"""
|
||||
PASSING = (1, 153, 370, 371, 1634, 24678051, 115132219018763992565095597973971522401)
|
||||
FAILING = (-153, -1, 0, 1.2, 200, "A", [], {}, None)
|
||||
FAILING: tuple = (-153, -1, 0, 1.2, 200, "A", [], {}, None)
|
||||
|
||||
|
||||
def armstrong_number(n: int) -> bool:
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
from typing import Union
|
||||
|
||||
|
||||
def median(nums: Union[int, float]) -> Union[int, float]:
|
||||
def median(nums: list) -> Union[int, float]:
|
||||
"""
|
||||
Find median of a list of numbers.
|
||||
Wiki: https://en.wikipedia.org/wiki/Median
|
||||
|
||||
>>> median([0])
|
||||
0
|
||||
>>> median([4,1,3,2])
|
||||
>>> median([4, 1, 3, 2])
|
||||
2.5
|
||||
>>> median([2, 70, 6, 50, 20, 8, 4])
|
||||
8
|
||||
|
|
|
@ -33,8 +33,8 @@ def harmonic_series(n_term: str) -> list:
|
|||
['1']
|
||||
"""
|
||||
if n_term == "":
|
||||
return n_term
|
||||
series = []
|
||||
return []
|
||||
series: list = []
|
||||
for temp in range(int(n_term)):
|
||||
series.append(f"1/{temp + 1}" if series else "1")
|
||||
return series
|
||||
|
|
Loading…
Reference in New Issue
Block a user