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
-
Ouellette Corporation began operations on January 2. Its year end is December 31, and it adjusts its accounts annually. Selected transactions for the current year follow: 1. On January 2, purchased...
-
Assume that in an annual audit of Webber AG at December 31, 2019, you find the following transactions near the closing date. 1. A special machine, fabricated to order for a customer, was finished and...
-
Evans \& Sons, Inc., is authorized to issue one million shares of \(\$ 1\) par value common stock. In the company's initial public offering, 500,000 shares are sold to the investing public at a price...
-
The stockholders equity of TVX Company at the beginning of the day on February 5 follows: Common stock $ 10 par value, 150,000 shares authorized, 60,000 shares issued and outstanding . . . . . . . ....
-
A well-done randomized trial was conducted in which 2,763 women with a history of coronary heart disease were randomly assigned in equal proportion to: a) A regimen of 0.625 mg/day of conjugated...
-
The case study shown below provides an overview of Road Transit Systems (RTS) - a specialist preventative vehicle maintenance program operator in NSW, Australia. A number of attributes have been...
-
A teacher relies 100% on the company-provided electronic tablet device (Teacher Tablet) to deliver lessons. The tablet literally tells the teacher exactly what to say, and exactly when to say it, for...
-
Qualitative variables describe how much or how many of something there is. In Exercises 1114, determine whether the statement is true or false. If the statement is false, rewrite it as a true...
-
In a study, 200 patients with skin cancer are randomly divided into two groups. One group receives an experimental drug and the other group receives a placebo. Is this a randomized experiment or an...
-
A _______ sample is one in which the population is divided into groups and a random sample of groups is drawn. In Exercises 712, fill in each blank with the appropriate word or phrase.
-
An e-store that sells cell phone accessories reports that 98% of its customers are satisfied with the speed of delivery. In Exercises 916, specify the type of bias involved.
-
Variables that classify individuals into categories are called _____________. In Exercises 510, fill in each blank with the appropriate word or phrase.
-
# 28 In 20x1 a city issues $1 million of 10% bonds to fund a capital improvement. The bonds were issued at par value on April 1 . Interest is due every 6 months from the issue date. What amount of...
-
(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
-
The following information is available for The Philippi Winery Company, Inc. Calculate the companys cost of equity capital for 2015, 2014, and 2013 using the Capital Asset Pricing Model discussed....
-
The 2015 annual report of The Procter & Gamble Company (P&G) is available at www.pginvestor.com. After reviewing P&Gs annual report, respond to the following questions: a. Prepare common-size income...
-
Consider a publicly held company whose products you are familiar with. Some examples might include: Access the companys public website and search for its most recent annual report. (Some companies...
Study smarter with the SolutionInn App