Write a program in Python including the following functions: a) Write a function that takes a...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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. Ⓒ 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. Ⓒ
Expert Answer:
Answer rating: 100% (QA)
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 the full answer
Related Book For
Numerical Methods With Chemical Engineering Applications
ISBN: 9781107135116
1st Edition
Authors: Kevin D. Dorfman, Prodromos Daoutidis
Posted Date:
Students also viewed these programming questions
-
Why According to one side of the argument, implementing regulations of climate change that would affect the private sector would lead to job losses and economic collapse, while The opposing...
-
What functions are there in the mazeAsn4 module: print_maze(maze) Description: This function displays the maze. The accessible cells are labelled G i.e. green, the blocked cells are labelled R i.e....
-
Case Study: Quick Fix Dental Practice Technology requirements Application must be built using Visual Studio 2019 or Visual Studio 2017, professional or enterprise. The community edition is not...
-
You and Sam have been in touch since the Palm Beach Business Development Luncheon, and he has expressed interest in your working on his business audit. The two of you make plans to meet for lunch,...
-
High school students across the nation compete in a financial capability challenge each year by taking a National Financial Capability Challenge Exam. Students who score in the top 20 percent are...
-
Tim Rian, a friend of yours, has recently purchased a home for $125,000, paying $25,000 down and the remainder financed by a 6.5%, 20-year mortgage, payable at $745.57 per month. At the end of the...
-
Find a form for a voluntary dismissal in a California court.
-
One observer argues that external equity should always be the primary concern in compensation, noting that it attracts the best employees and prevents the top performers from leaving.
-
How can you simultaneously hedgetransactionexposure andtranslationexposure of the same firm? What are the argumentsagainsta MNC hedging transaction exposure? Why should companiesnot hedge? What are...
-
On July 31, 2019, Ping Company purchased 90% of Santos Company?s common stock for $2,010,000 cash. Immediately after the acquisition, the two companies? balance sheets were as follows: Santos Company...
-
Describe and illustrate the process of normalizing (step by step from 1NF till BCNF) the relation shown below to BCNF. Indicate the Primary Keys (PK) as well as the Foreign Keys (FK) for each new...
-
A.Discuss the following: 1. What is the difference between press release and newsletter? 2. Enumerate the purposes of writing press release and newsletter? 3. Discuss the elements of writing press...
-
Burger King Corp. is a Florida corporation with principal offices in Miami. It principally conducts restaurant business through franchisees. The franchisees are licensed to use Burger King's...
-
What is the difference between a press release and a communication press release?
-
EY's review report on Nestl's environmental and social indicators includes a description of each Key Performance Indicator (KPI) and a reported value. Environmental Greenhouse Gas (GHG) emissions...
-
You were hired as a consultant to Peel Plastics, whose target capital structure is 50% debt, 10% preferred, and 40% common equity. The interest rate on new debt is 4.50%, the yield on the preferred...
-
If the 25 k2 + 30K + 9 is a perfect square. find the value of k.
-
Economic feasibility is an important guideline in designing cost accounting systems. Do you agree? Explain.
-
Determine the output of the sum 10.3 + 0.442 using 3 bits of precision.
-
Write a MATLAB program that uses finite difference to solve on x [0, 1] subject to y(0) = 1 and y(1) = 0 and on x [0, 1] subject to y(0) = 1 and y(1) = 0. Use the solution to the linear problem, y...
-
Imagine that I have integrated the autonomous IVP using some method and at step n I have a value yn. Under what conditions will explicit Euler and predictorcorrector yield the same result for y n+1 ?...
-
Draw the acceleration diagram for the shaper mechanism shown in Fig.3.20(a). \(O B=150 \mathrm{~mm}\), \(C B=225 \mathrm{~mm}, O C=150 \mathrm{~mm}\). Find the coriolis acceleration of slider \(B\)....
-
In the crank and slotted lever type quick return motion mechanism shown in Fig.3.14(a), the crank \(A B\) rotates at \(120 \mathrm{rpm}\). Determine (a) velocity of ram at \(D\), (b) magnitude of...
-
In the swivelling joint mechanism shown in Fig. 3.17 (a), \(A B=300 \mathrm{~mm}, B C=800 \mathrm{~mm}, C D=400 \mathrm{~mm}\), \(A D=500 \mathrm{~mm}, B E=400 \mathrm{~mm}, E F=500 \mathrm{~mm}, E...
Study smarter with the SolutionInn App