Answered step by step
Verified Expert Solution
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
/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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started