A Cengage Group learning activity needs to validate whether a learner's selected values contain a pair matching a required total. Given an unsorted array of integers and a target integer, determine whether two distinct array elements add up exactly to the target.
Return True if such a pair exists, and False otherwise. An element may not be used twice, but duplicate values at different indices may form a valid pair.
Implement has_pair_with_sum(nums, target):
nums, a list of integers, and target, an integer.i and j satisfy nums[i] + nums[j] == target.def has_pair_with_sum(nums, target):