Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(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.

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Access Patterns Database Interactions In Object Oriented Applications

Authors: Clifton Nock

1st Edition

0321555627, 978-0321555625

More Books

Students also viewed these Databases questions

Question

2 What supply is and what affects it.

Answered: 1 week ago