Question: (Q3)Complete the following functions. (i) The first function should search for the first occurrence of a value (val) in a list (list), and then return

(Q3)Complete the following functions.

(i) The first function should search for the first occurrence of a value (val) in a list (list), and then return the value that follows it in the list.

def returnNext(list, val)

The function should return None if the value is not found in the list, or there is no value coming after it (i.e. the value is the last in the list)

Assume the parameter list is always a list.

(Q4)

The second function returns True if two lists of numbers have the same sum. It returns False if otherwise.

def equalSum(list1, list2)

The function should return None if any of the input lists is None or not a list of integers.

(iii) Complete the following definition of function that compares if two strings are the same.

def compareIgnoreSpace(str1, str2)

However, for this function, spaces are ignored in the comparison. Therefore, two strings are still considered the same if, after all the spaces are removed from them, they have exactly the same content. The parameters str1 and str2 contain the two strings for comparison. The function should return 1 if the two strings are the same, and return 0 if otherwise.

(Q3)Complete the following functions. (i) The first function should search for the

Parameter stri "abc" Parameter str2 "abc" Return value 1 "ab ab 1 "abcd" 0 "aaaa" 1

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!