Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 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
Step: 1
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 ...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