[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:
imp 2021-08-18 18:45:07 +08:00 committed by GitHub
parent 4545270ace
commit af0810fca1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 5 deletions

View File

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

View File

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

View File

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