1. Lists, comprehensions, loops and slicing. a) Create a list comprehension of multiples of 4 from...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
1. Lists, comprehensions, loops and slicing. a) Create a list comprehension of multiples of 4 from 0 to 40 inclusive. The elements will be the multiples of 4 from the 0 multiple to the 10th multiple (11 elements). b) Print this list as displayed in the output example. c) Create a second empty list. d) Use a loop to insert all elements from the first list to the second list. Before storing into the new list, divide each copied element by 2. This results in a new list of all multiples of 2 from 0 to 20 inclusive. The elements will be the multiples of 2 from the 0 multiple to the 10th multiple (11 elements). e) Print the second list as displayed in the output example. f) Use slicing to copy the second list to a new third list. g) Use a loop to divide and store each element of the third list by 2. This will result in a list of the numbers 0 to 10 inclusive. h) Print the third list as displayed in the output example. Output Example [0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40] [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20] [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] 1. Lists, comprehensions, loops and slicing. a) Create a list comprehension of multiples of 4 from 0 to 40 inclusive. The elements will be the multiples of 4 from the 0 multiple to the 10th multiple (11 elements). b) Print this list as displayed in the output example. c) Create a second empty list. d) Use a loop to insert all elements from the first list to the second list. Before storing into the new list, divide each copied element by 2. This results in a new list of all multiples of 2 from 0 to 20 inclusive. The elements will be the multiples of 2 from the 0 multiple to the 10th multiple (11 elements). e) Print the second list as displayed in the output example. f) Use slicing to copy the second list to a new third list. g) Use a loop to divide and store each element of the third list by 2. This will result in a list of the numbers 0 to 10 inclusive. h) Print the third list as displayed in the output example. Output Example [0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40] [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20] [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
Expert Answer:
Answer rating: 100% (QA)
Here is a Python code solution for the problem you provided python Create a list comprehension of mu... View the full answer
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
The diffusivity of C in -ferrite (BCC iron) and diffusivity of C in y-austenite (FCC iron) is given at two temperatures: Diffusivity [m/s] Temperature [C] Diffusivity [m/s] C in y-Fe 500 --- 900 1100...
-
Let A, B be sets. Define: (a) the Cartesian product (A B) (b) the set of relations R between A and B (c) the identity relation A on the set A [3 marks] Suppose S, T are relations between A and B, and...
-
QUIZ... Let D be a poset and let f : D D be a monotone function. (i) Give the definition of the least pre-fixed point, fix (f), of f. Show that fix (f) is a fixed point of f. [5 marks] (ii) Show that...
-
X = {a,b,c,d. e, f} olmak zere (X.) ksmi sral kmesinin grafii aada verilmitir. (a) (X.) ksmi sral kmesinin maksimal, minimal, minimum ve maksimum elemanlarn belirtiniz. (b) (X.) kismi sral kmesinin Y...
-
Husky Energy Inc. is one of Canada's largest integrated energy companies. It is headquartered in Calgary, Alberta, and its shares are traded on the Toronto Stock Exchange under the symbols HSE. Husky...
-
A standardized biological microscope has an 8.0-mm-focal-length objective. What focal-length eyepiece should be used to achieve a total magnification of 100?
-
Integrated Accounting allows for accounts payable and payroll checks to be prepared manually or by computer. (True/False)
-
Frame the Mattco case using the factors set forth in this chapter. Specific areas that should be addressed in this exercise include: a. Type of case b. Jurisdiction c. Professional standards d....
-
Use PMT= Round to the nearest dollar. -nt 1- 1+ n Suppose that you decide to buy a car for $25,278, including taxes and license fees. You saved $6,000 for a dov payment and can get a five-year loan...
-
Please focus on Q4 & Q5, Thanks. 1. A venture capital firm invests $5 million in NewCo in exchange for 20% of the company's equity. What is NewCo's post-money valuation? What is its pre-money valu...
-
Communication is an essential means to convey important information to the organization. Or it can provide other information such as events, benefits and many other situations. How effective can an...
-
The following data pertains to a defined benefit (DB) pension plan: defined benefit obligation, December 31, 2015 30,000 long-term interest rate on corporate bonds 8% past service cost, December 31,...
-
Q6. Prove that sin5x-2sin3x+sinx cas5x-casx = tank.
-
Adam issued $90,000 of 10-year, 5% bonds payable on January 1, 2016. Adam pays interest each January 1 and July 1 and amortizes discount or premium by the straight-line amortization method. The...
-
h) If a matrix has 12 elements, what are the possible orders it can have. i) Write equation y = 3x + 2 in intercept form. -5 12 j) If cosx = x lies in second quadrant, find value of tanx.
-
How are generations defined? A arbitrarily, changing from culture to culture B clearly, based on demographic changes that take place every 5 years C arbitrarily, representing 15- to 20-year periods D...
-
Write each fraction as a percent. 7 50
-
Clifford Johnson has a limited partnership investment and a rental condominium. Clifford actively manages the rental condominium. During 2012, his share of the loss from the limited partnership was...
-
If Charles, a 16-year-old child model, earns $50,000 a year and is completely self supporting even though he lives with his parents, can his parents claim him as a dependent? Why or why not?...
-
The following additional information is available for the Dr. Ivan and Irene Incisor family from Chapters 1-7. Ivan sold the following securities during the year and received a Form 1099-B that...
-
What are the key elements of working capital?
-
From the extracts of data provided below for Easy Events, calculate the ratios the following ratios and explain what they reveal. a) ROCE b) Asset utilisation c) Net profit percentage d) Gross profit...
-
Name the three working capital policies a business can follow.
Study smarter with the SolutionInn App