3. Write a Python function concat_list() that accepts a list containing string values and an integer...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
3. Write a Python function concat_list() that accepts a list containing string values and an integer as input and prints out a new list where each element in the list is concatenated with all integers from 1 to n. You only need to check the following testing case and print out the results as shown below. You can directly assign values to the input list and integer (i.e. no need to use an input() function). The input list is ['a', 'b', 'c', 'd']. The Input Integer is 5. The new list is ['1", "a2', 'at', 'a4', 'as", "b1', 'b2', '63', '64", "b5", "c1', 'c2', 'c3', 'c4', 'cs", "d1", "d2', '3', 'd 4', 'ds']. 4. Write a Python program that accepts a colon-separated sequence of words as input and prints the unique words in sorted form (alphanumerically). 524 Please enter a sequence of words seperated by colons:good:no:yes: hello: da y: good: hello The new sorted list is: ['day', 'good', 'hello', 'no', 'yes'] Please enter a sequence of words seperated by colons:good no yes The sequence is not seperated by colons 5. Step 1: Use list comprehension expression to create a list to include elements that satisfy the following two criteria: (1) All elements are integers between 1 and 20 (inclusive); (2) All elements are not divisible by 3 nor by 5. Print out the list and move to the next step. Step 2: Convert all elements that are divisible by 2 to their opposites (e.g. 2 to -2) and print out the new list (step-2 list). Step 3: Sum up the value of all positive elements in the step-2 list and print out the result. You can use the following format to print out your results. My initial list is: My step-2 list is: The sum of positive elements in my step-2 list is: C EC ANO F 3. Write a Python function concat_list() that accepts a list containing string values and an integer as input and prints out a new list where each element in the list is concatenated with all integers from 1 to n. You only need to check the following testing case and print out the results as shown below. You can directly assign values to the input list and integer (i.e. no need to use an input() function). The input list is ['a', 'b', 'c', 'd']. The Input Integer is 5. The new list is ['1", "a2', 'at', 'a4', 'as", "b1', 'b2', '63', '64", "b5", "c1', 'c2', 'c3', 'c4', 'cs", "d1", "d2', '3', 'd 4', 'ds']. 4. Write a Python program that accepts a colon-separated sequence of words as input and prints the unique words in sorted form (alphanumerically). 524 Please enter a sequence of words seperated by colons:good:no:yes: hello: da y: good: hello The new sorted list is: ['day', 'good', 'hello', 'no', 'yes'] Please enter a sequence of words seperated by colons:good no yes The sequence is not seperated by colons 5. Step 1: Use list comprehension expression to create a list to include elements that satisfy the following two criteria: (1) All elements are integers between 1 and 20 (inclusive); (2) All elements are not divisible by 3 nor by 5. Print out the list and move to the next step. Step 2: Convert all elements that are divisible by 2 to their opposites (e.g. 2 to -2) and print out the new list (step-2 list). Step 3: Sum up the value of all positive elements in the step-2 list and print out the result. You can use the following format to print out your results. My initial list is: My step-2 list is: The sum of positive elements in my step-2 list is: C EC ANO F
Expert Answer:
Answer rating: 100% (QA)
Question 3 Heres the Python function concatlist Python def concatlistlist1 n newlist for item ... View the full answer
Related Book For
Practical Management Science
ISBN: 978-1305250901
5th edition
Authors: Wayne L. Winston, Christian Albright
Posted Date:
Students also viewed these programming questions
-
The risk free rate is currently 2% and the required return on the market portfolio is 8%.If a specific stock is estimated to have a CAPM beta coefficient of 1.2 and the $2.00 per share dividend paid...
-
Graph the sets of points whose polar coordinates satisfy the equations and inequalitie. 0 , r = 1
-
Fritz Maytag, owner of Anchor Steam, says, "Just because you are the best around doesn't mean that you have to franchise or even expand. You can stay as you are and have a business that's profitable...
-
In Exercises evaluate the definite integral. Use a graphing utility to verify your result. (/2 /4 (2-csc x) dx
-
Derive the expression of work done by the compressor in isothermal compression, adiabatic compression, and polytropic compression.
-
Factoring Receivables your firm has an average collection period of 38 days. Current practice is to factor all receivables immediately at a 2 percent discount. What is the effective cost of borrowing...
-
Find support reactions for a beam shown below. 3 kN 2 kN/m 30 A 1 m 1 m (a) Original beam 2 m UNA B
-
Harriet's Hats is a retailer who buys hats from a manufacturer and then sells them in its stores. The following information includes the company's December 31, 20Y8 Balance Sheet and the details of...
-
A manufacturer has budgeted sales for the first quarter of the next year to be 30,000 units. The inventory in hand at the beginning of quarter is 5,000 units. The desired ending inventory is 10,000...
-
17. For the first 1200 m of a 1500-m race, a runner's average speed is 6.14 m/s. To finish in under 4 minutes, the runner's average speed for the remainder of the race must be at least (a) 6.73 m/s;...
-
Explain organizational development and provide one major trend that is shaping change in organizations.
-
If a 4.00 g effervescent antacid tablet is dissolved in 95 mL (95 g) of water in a 110. g glass, how much will the glass and its contents weigh once the antacid pill has dissolved? O a bit more than...
-
A man is pulling a box with a rope attached to it which is making an angle of 53 with the horizontal surface. If the force applied by the man is 7.9 N and the box is displaced by 10.0 m along the...
-
What approach to strategic Human Resource Management does Netflix adopt?
-
Concrete has a coefficient of linear expansion of about 8 10-6 /C. If you were to build a bridge from concrete panels, you would have to leave a gap between them so that the concrete panels would...
-
Use translations to graph f. f(x) = x-/2 +1
-
In Example 9.2, the fixed costs are split $4 million for development and $2 million for marketing. Perform a sensitivity analysis where the sum of these two fixed costs remains at $6 million but the...
-
On average, 40 cars per hour are tempted to use the drive-through window at the Hot Dog King Restaurant. (We assume that inter-arrival times are exponentially distributed.) If a total of more than...
-
In the first (R,Q) model in Example 12.6, the one with a shortage cost, we let both Q and the multiple k be changing cells. However, we stated that the optimal Q depends mainly on the fixed ordering...
-
True or False: When multiple independent, divisible investments are available, form the investment portfolio so that the internal rate of return is maximized.
-
Polaris Industries has \(\$ 1,250,000\) available for additional innovations on the Victory Vision motorcycle. These include the five indivisible, equal-lived alternatives, each of which guarantees...
-
Consider a capital budgeting formulation where the binary variables \(x_{1}\) and \(x_{2}\) are used to represent the acceptance \(\left(x_{i}=1 ight)\) or rejection \(\left(x_{i}=0 ight)\) of each...
Study smarter with the SolutionInn App