list_ops module¶
Module for performing several basic operations on lists of integers.
-
exception
list_ops.
BadNumbersException
¶ Bases:
exceptions.Exception
-
list_ops.
check_inputs
(input_list)¶ Checks if input list fits desired format
Parameters: input_list – list of n integers between -9,000 and 9,000
Raises: - TypeError – Input must be lists
- TypeError – Input elements must be integers
- ValueError – All input elements must be between -9,000 and 9,000 (inclusive)
- BadNumbersException – Numbers 123 and 321 cannot be in same list
-
list_ops.
get_max_diff
(input_list)¶ Returns maximum difference between consecutive elements in input list
Parameters: input_list – list of n integers between -9,000 and 9,000
Returns: maximum difference d defined by d = input_list[i+1] - input_list[i] for i = 0 to n-1
Raises: - ImportError – If Numpy is not installed
- TypeError – Input must be lists
- TypeError – Input elements must be integers
- ValueError – All input elements must be between -9,000 and 9,000 (inclusive)
- BadNumbersException – Numbers 123 and 321 cannot be in same list
-
list_ops.
get_min_max
(input_list)¶ Returns min and max in a list
Parameters: input_list – (int) list to get min and max of
Returns: min and max of list in a tuple
Raises: - TypeError – Input must be lists
- TypeError – Input elements must be integers
- ValueError – All input elements must be between -9,000 and 9,000 (inclusive)
- BadNumbersException –
- BadNumbersException – Numbers 123 and 321 cannot be in same list
-
list_ops.
get_sum
(input_list)¶ Returns the sum of a list
Parameters: input_list – list of n integers between -9,000 and 9,000
Returns: sum of all the n integers in the list
Raises: - TypeError – Input must be lists
- TypeError – Input elements must be integers
- ValueError – All input elements must be between -9,000 and 9,000 (inclusive)
- BadNumbersException – Numbers 123 and 321 cannot be in same list
-
list_ops.
import_modules
()¶ Imports required module (Numpy)
Returns: the module Numpy