Write a program to convert a list of numbers into its squares For this question, use...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a program to convert a list of numbers into its squares For this question, use a for loop first (as one way), and list comprehension (as the second) original (1, 2, 3, 4, 5, 6, 7) for loop: [1, 4, 9, 16, 25, 36, 49] list comprehension: [1, 4, 9, 16, 25, 36, 49) Concatenate two lists in the following order 1.3 (5 points) Concatenate two lists in the following order: Use the list comprehension to iterate for this question. list1= ["North", "East "] list2 = ["South", "West"] results ['North South', 'North West', 'East South', 'East West'] 1.4 (10 points) Write a program to iterate both lists simultaneously and display items from list1 in original order and from list2 in reverse order simultaneously. This is similar to ex1.1 except for the second list zip parameter (zip(list1, list2[::-1]) needs to be from the back. list1= [10, 20, 30, 40] list2 = [100, 200, 300, 400] output: 10 400 20 300 30 200 40 100 Write a program to convert a list of numbers into its squares For this question, use a for loop first (as one way), and list comprehension (as the second) original (1, 2, 3, 4, 5, 6, 7) for loop: [1, 4, 9, 16, 25, 36, 49] list comprehension: [1, 4, 9, 16, 25, 36, 49) Concatenate two lists in the following order 1.3 (5 points) Concatenate two lists in the following order: Use the list comprehension to iterate for this question. list1= ["North", "East "] list2 = ["South", "West"] results ['North South', 'North West', 'East South', 'East West'] 1.4 (10 points) Write a program to iterate both lists simultaneously and display items from list1 in original order and from list2 in reverse order simultaneously. This is similar to ex1.1 except for the second list zip parameter (zip(list1, list2[::-1]) needs to be from the back. list1= [10, 20, 30, 40] list2 = [100, 200, 300, 400] output: 10 400 20 300 30 200 40 100
Expert Answer:
Related Book For
Introduction to Java Programming, Comprehensive Version
ISBN: 978-0133761313
10th Edition
Authors: Y. Daniel Liang
Posted Date:
Students also viewed these programming questions
-
A mutual fund has $450 million in assets and liabilities of $10 million. If the fund has 44 million shares outstanding, what is its NAV? If an investor redeems 1,000,000 shares, what happens to the...
-
9.1 Exercise (JDK Source Code): Extract the source code of the class Math from the JDK source code ("$JAVA_HOME" "src.zip" "Math.java" under folder "java.lang"). Study how constants such as E and...
-
Consider the following list of projects: Note: NPV stands for Net Present Value, and PI stands for Profitability Index. Pl is calculated as the ratio of NPV/Investment. Project A B C D E F G H I J...
-
Repeat Example 13.1, but for electrophilic substitution at C-2 or C-4 of pyridine. Explain why substitution at C-3 (eq. 13.2) is preferred. 4 H
-
1. We know that there must be dark matter in the universe because (a) We see dark dust clouds. (b) We see that the universe is expanding. (c) We see that stars far from the galactic center are moving...
-
Solomon (1983) details the following biological model. Suppose that each of a random number, N, of insects lays Xi eggs, where the Xts are independent, identically distributed random variables. The...
-
MC Electronics is considering two plans for raising \(\$ 1,000,000\) to expand operations. Plan A is to issue \(9 \%\) bonds payable, and plan B is to issue 100,000 shares of common stock. Before any...
-
Quad Enterprises is considering a new three-year expansion project that requires an initial fixed asset investment of $2.9 million. The fixed asset will be depreciated straight-line to zero over its...
-
Q1 Three partners choose to go the start-up way. They run a chain of Pet Spa across Mumbai and Pune. For the accounting year 2022, their business observes increasing prices for materials. Hence,...
-
You and a classmate are assigned a project on which you will receive one combined grade. You each want to receive a good grade, but you also want to avoid hard work. In particular, here is the...
-
You are the financial manager of Toy Store Ltd. The company is planning to introduce a new range of educational toys called the Edu-Fun. The production of the new range will be at the company's...
-
What are the advantages and disadvantages of common missing data methods?
-
Describe how your thinking has changed about nursing research and evidence-based practice over the past 8 weeks; describe one new learned item during this course that you believe was the most helpful?
-
1. On May 1, Fiona Nash formed a computer consulting business. In order to start the business, she invested $20,000 in equipment. Enter the appropriate amounts into the accounting equation format. 2....
-
Describe a sociological theory that can be use to develop childhood obesity?
-
If you could pump water to a height of 300 meters, say to a reservoir on a mountain above a generating station, how much water by volume would have to be moved to provide 3.5 GW of power for 24...
-
3 7 While there equipment is considered reliable, experience dictates that the following level of epairs will likely be for the period of the warranty, and a discount rate of 10% is appropriate. This...
-
(a) Use integration by parts to show that (b) If f and g are inverse functions and f' is continuous, prove that (c) In the case where f and t are positive functions and b > a > 0, draw a diagram to...
-
Write a method that displays an n-by-n matrix using the following header:public static void printMatrix(int n)Each element is 0 or 1, which is generated randomly. Write a test program that prompts...
-
Write a program that enables the user to specify the location and size of the rectangles and displays whether the two rectangles intersect, as shown in Figure 16.39b. Enable the user to point the...
-
Write a program to compute the following summation. 1 1 1 1 1 + V2 Vi + V3 V624 + V625 V3 + V4
-
Consider a bivariate time series \(\boldsymbol{z}_{t}\), where \(z_{1 t}\) is the change in monthly U.S. treasury bills with maturity 3 months and \(z_{2 t}\) is the inflation rate, in percentage, of...
-
Consider the growth rates, in percentages, of the quarterly real GDP of United Kingdom, Canada, and the United States used in the chapter. Fit a VAR(4) model to the series, simplify the model by...
-
Consider the U.S. quarterly gross private saving (GPSAVE) and gross private domestic investment (GPDI) from first quarter of 1947 to the third quarter of 2012. The data are from the Federal Reserve...
Study smarter with the SolutionInn App