Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

/hich of the following will apply the squ () function to the list of numbers [1,2,3] (namely, it will print [1,4,9] as output)? def recursive_map

image text in transcribed

image text in transcribed

/hich of the following will apply the squ () function to the list of numbers [1,2,3] (namely, it will print [1,4,9] as output)? def recursive_map (func, seq): if seq =[] : return seq else: return recursive_map (func, seq [1:] ) + [func(seq[0])] print(recursive_map(sq, [1,2,3]) ) def iterative_map(func, seq): for i in range (len (seq)): x= seq [i:] new_sequence.append (func (seq [x[0]]) ) return new_sequence def iterative map(func, seq): for i in seq: new_sequence.insert (func(i),i) return new_sequence new_sequence = [] print(iterative map(sq, [1,2,3,9])) def recursive map(func, seq): if seq = []: return seq preturn [func(seq[0])] + recursive_map (func, seq [1: 1 )

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions

Question

=+221 .1 Answered: 1 week ago

Answered: 1 week ago