Question: Write a program in Python including the following functions: a) Write a function that takes a list and 2 integers x and y as

Write a program in Python including the following functions: a) Write a function that takes a list and 2

Write a program in Python including the following functions: a) Write a function that takes a list and 2 integers x and y as parameter and performs the following: If the list has an even number of elements, inserts y number of x's in the middle of the list. Otherwise, inserts y number of x's to the end of the list Returns the list. Sample Run: 1st=[2,3,4,5] 1st=fun (1st, 9,2) [2, 3, 9, 9, 4, 5] b) Write a function which takes a list of integer digits and an integer as parameter (to store powers of 10) and returns an integer which is composed of the digits in the list. Sample Run: print (form(1st, 1)) #for 1st [2,3,9,9,4,5] 239945 c) Call the first function, and send the returning list to the second function. You do not need to input anything. Note: You can use list functions, but no loops and no type conversion. Recursion is allowed.

Step by Step Solution

3.47 Rating (173 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Python code for question a def funlst x y if lenlst 2 0 middle lenlst 2 lstmiddlemiddle x y else lstextendx y return lst Sample list lst 2 3 4 5 Step ... View full answer

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 Programming Questions!