Improved numbered queries
This commit is contained in:
@@ -9,6 +9,9 @@ def avg_query(_list: IterableABC, _func: Callable) -> Union[int, float, complex]
|
||||
if _list is None:
|
||||
raise ArgumentNoneException(ExceptionArgument.list)
|
||||
|
||||
if _func is None and not is_number(_list.type):
|
||||
raise InvalidTypeException()
|
||||
|
||||
average = 0
|
||||
count = len(_list)
|
||||
|
||||
@@ -19,9 +22,6 @@ def avg_query(_list: IterableABC, _func: Callable) -> Union[int, float, complex]
|
||||
else:
|
||||
value = element
|
||||
|
||||
if _func is None and type(element) != _list.type or not is_number(type(value)):
|
||||
raise WrongTypeException()
|
||||
|
||||
average += value
|
||||
|
||||
return average / count
|
||||
|
@@ -10,6 +10,9 @@ def max_query(_list: IterableABC, _func: Callable) -> Union[int, float, complex]
|
||||
if _list is None:
|
||||
raise ArgumentNoneException(ExceptionArgument.list)
|
||||
|
||||
if _func is None and not is_number(_list.type):
|
||||
raise InvalidTypeException()
|
||||
|
||||
max_value = 0
|
||||
for element in _list:
|
||||
if _func is not None:
|
||||
@@ -17,9 +20,6 @@ def max_query(_list: IterableABC, _func: Callable) -> Union[int, float, complex]
|
||||
else:
|
||||
value = element
|
||||
|
||||
if _func is None and type(value) != _list.type or not is_number(type(value)):
|
||||
raise WrongTypeException()
|
||||
|
||||
if value > max_value:
|
||||
max_value = value
|
||||
|
||||
@@ -30,6 +30,9 @@ def min_query(_list: IterableABC, _func: Callable) -> Union[int, float, complex]
|
||||
if _list is None:
|
||||
raise ArgumentNoneException(ExceptionArgument.list)
|
||||
|
||||
if _func is None and not is_number(_list.type):
|
||||
raise InvalidTypeException()
|
||||
|
||||
min_value = 0
|
||||
is_first = True
|
||||
for element in _list:
|
||||
@@ -38,9 +41,6 @@ def min_query(_list: IterableABC, _func: Callable) -> Union[int, float, complex]
|
||||
else:
|
||||
value = element
|
||||
|
||||
if _func is None and type(value) != _list.type or not is_number(type(value)):
|
||||
raise WrongTypeException()
|
||||
|
||||
if is_first:
|
||||
min_value = value
|
||||
is_first = False
|
||||
|
Reference in New Issue
Block a user