18. Write a python function to check whether the summation of any two number in list a and list b equal to a given number.
The output is:
list_a = [11, 6, 1, 4]
list_b = [21, 17, 4, 8]
Expected Answer:
True
False
Sample Answer:
def check_sum(nums, k):
for i in range(len(nums)):
for j in range(i+1, len(nums)):
if nums[i] + nums[j] == k:
return True
return False
list_a = [11, 6, 1, 4]
list_b = [21, 17, 4, 8]
print(check_sum(list_a, 10))
print(check_sum(list_b, 40))
More Exercises:
Python String ExercisesMore Numpy Exercises:
Numpy String ExercisesMore Pandas Exercises:
Pandas Series ExercisesMore Tutorials:
Python Installation - Linux (Ubuntu)