Question: # q10 - create function countPairs() to meet the conditions below # - accept one list of arbitrary integer values and an integer as parameters
# q10 - create function countPairs() to meet the conditions below # - accept one list of arbitrary integer values and an integer as parameters # - add a meaningful docstring # - find every possible pair in the list that when add up # is equal to the integer value # - returns the number of pairs # --- e.g. [2,5,8] and 8 -> returns 0 # --- e.g. [2,3,4,5] and 7 -> returns 2 because # (4,3),(2,5) (note that (3,4) and (4,3) are same pair and should # be counted only once, (same for (2,5) and (5,2))) # --- e.g. [1,2,3,4] and 6 -> returns 1 because # (2,4) (note: numbers should not be added to themselves. For example # (3,3) could not be counted as one of the pairs. # # - you may assume there is no duplication in the list # Restriction: None # # - param: list # integer # - return: integer
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
