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
-
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...
-
A fire destroyed the inventory of Bronk Supplies, but the accounting records were saved. The beginning inventory was $31,500, purchases for the period were $68,250, and sales were $120,000. Bronk's...
-
A company had the following transactions during its most recent fiscal period: 1. A total of 5,000 shares were issued at $30 per share. 2. Equipment worth $120,000 was purchased for $80,000 cash and...
-
Describe object-relational mapping. What are the required steps?
-
Here are two useful rules of thumb. The Rule of 72 says that with discrete compounding the time it takes for an investment to double in value is roughly 72/interest rate (in percent). The Rule of 69...
-
Helping Hand Hobby Stores has just paid an annual dividend of $1.20 a share. The company's policy is to increase the dividend at an annual rate of 5.4 percent. What's the current value of the stock...
-
You are applying for a job and been selected for the position. You need to negotiate when you sign your work contract for the new job. 4. What do you need to do to be prepared for the job contract...
-
The basis for DNase I footprinting is that the binding of a protein to DNA a. prevents the DNA from being digested with a restriction enzyme. b. enhances the ability of the DNA to be digested with a...
-
Which is the proper order of the following steps in a genecloning experiment involving vectors? 1. Add DNA ligase. 2. Incubate the chromosomal DNA and the vector DNA with a restriction enzyme. 3....
-
On April 18, 2018, Jane Juniper purchased 30 shares of Bryan Corp. stock for \(\$ 210\), and on September 29, 2018, she purchased 90 additional shares for \(\$ 900\). On November 28,2018 , she sold...
-
The likelihood of any particular base in a given position is 1/4 (because there are 4 types of bases) and the likelihood of a purine is 1/2. If you assume random base arrangements, the likelihood of...
-
How would you set up crosses to determine if a gene is Y-linked versus X-linked?
-
In a public-key system using RSA, you intercept the ciphertext C = 10 sent to a user whose public key is e = 5, n = 35. What is the plaintext M?
-
In Exercises 15 through 30, find the derivative dy/dx. In some of these problems, you may need to use implicit differentiation or logarithmic differentiation. y ex + et -2x 1 + e
-
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...
-
(a) Show that the variancecovariance matrix of the disturbances in (9.1) is given by (9.2). (b) Show that the two nonzero block matrices in (9.2) can be written as in (9.3). (c) Show that...
-
Consider the following unbalanced one-way analysis of variance model \[y_{i t}=\mu_{i}+u_{i t} \quad i=1, \ldots, N \quad t=1,2, \ldots, T_{i}\] where for simplicity's sake no explanatory variables...
-
Consider the three-way error component model described in problem 3.15. The panel data can be unbalanced and the matrices of dummy variables are \(\Delta=\left[\Delta_{1}, \Delta_{2}, \Delta_{3}...
Study smarter with the SolutionInn App