Given this list: list1= [5, 1, 2, 9] 1. What is the python statement used to...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Given this list: list1= [5, 1, 2, 9] 1. What is the python statement used to access the first element of the list (L.e., the value 5))? 2. What is the python statement used to access the last element of the list (i.e., the value 9))? 3. Answer question 2 above but use len [...] to access the last element of the list. Type your answers into python to check if you are right. 1-2: Suppose we have a string initialized as follows: stri = "5129" 1. What is the python statement used to access the first element of the string (i.e., the value 5))? 2. What is the python statement used to access the last element of the string (i.e. the value 9))? 3. Answer question 2 above but use len (...) to access the last element of the string. Reflection: The syntax for 1-1 and 1-2 is the same. Part 2: Creating and modifying lists Consider the following code (it may be on the next page depending on how long your answers are above): res1 - [] for i in range(5): 2 res1.append( i ) (a) print(res1) res2 - resi res2[0] - 99 print( res1) print( res2) DU res2 - [3,4] print(res1) (e) print( res2) (1) What is the code in the first for loop doing (see arrow #1)? Use plain English (not Python syntax) Sample answer: It adds numbers from 0 up to 4 to a list; afterward, the list is printed (2) What is the code in the first for loop doing (see arrow #2)? Use plain English (not Python syntax) Given this list: list1= [5, 1, 2, 9] 1. What is the python statement used to access the first element of the list (L.e., the value 5))? 2. What is the python statement used to access the last element of the list (i.e., the value 9))? 3. Answer question 2 above but use len [...] to access the last element of the list. Type your answers into python to check if you are right. 1-2: Suppose we have a string initialized as follows: stri = "5129" 1. What is the python statement used to access the first element of the string (i.e., the value 5))? 2. What is the python statement used to access the last element of the string (i.e. the value 9))? 3. Answer question 2 above but use len (...) to access the last element of the string. Reflection: The syntax for 1-1 and 1-2 is the same. Part 2: Creating and modifying lists Consider the following code (it may be on the next page depending on how long your answers are above): res1 - [] for i in range(5): 2 res1.append( i ) (a) print(res1) res2 - resi res2[0] - 99 print( res1) print( res2) DU res2 - [3,4] print(res1) (e) print( res2) (1) What is the code in the first for loop doing (see arrow #1)? Use plain English (not Python syntax) Sample answer: It adds numbers from 0 up to 4 to a list; afterward, the list is printed (2) What is the code in the first for loop doing (see arrow #2)? Use plain English (not Python syntax)
Expert Answer:
Answer rating: 100% (QA)
Solution Lets address your questions step by step For List 1 list1 To access the first element of th... 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
-
Vulcan Flyovers offers scenic overflights of Mount Saint Helens. Data concerning the company's operations in July appear below: Vulcan Flyovers Operating Data For the Month Ended July 31 Flights (q)...
-
Carol Harris, Ph.D, CPA, is a single taxpayer and she lives at 674 Yankee Street, Durham, NC 27409. Her Social Security number is 793-52-4335. Carol is an Associate Professor of Accounting at a local...
-
The following additional information is available for the Dr. Ivan and Irene Incisor family from Chapters 1-5. Ivan's grandfather died and left a portfolio of municipal bonds. In 2012, they pay Ivan...
-
Determine whether the given functions are even, odd, or neither. a. x sin(x) c. x cos(x) e. x sin(x) + x sin(x) f. x sin(x) + x cos(x) even h. x sin(x) + x cos(x) j. x cos (x) + x cos(x) b. x sin(x)...
-
A particle moves along the spiral shown. Determine the magnitude of the velocity of the particle in terms of b,, and . re=b
-
Suppose we are compiling for a machine with 1-byte characters, 2-byte shorts, 4-byte integers, and 8-byte reals, and with alignment rules that require the address of every primitive data element to...
-
Why are information security and privacy important considerations in the design, development, and maintenance of an HRIS?
-
Dillard Co. has sales revenue of $100,000, cost of goods sold of $70,000, and operating expenses of $18,000. What is its gross profit?
-
(A) We are given three diffent vectors: A = 6-3, B=-11+5j and C = A + B. (1) C = 2, (2) C = 51, (3) C = 5 + 2), (4) C=7+8 What is C in component form? A. 3 B. 1 C. 4 D. 2 Using the same three vectors...
-
Conroy Company manufactures two products-B100 and A200. The company provided the following information with respect to these products: B100 A200 Estimated customer demand (in units) Selling price per...
-
Should there be differences in the accounting and reporting systems between governments and businesses that provide the same services? A town privatized its sanitation department, selling all its...
-
Differentiate between accelerator principle of investment and investment multiplier. Explain the determinants of induced investment in an economy. Given C=a+bY, explain "a" and "b" and then sketch...
-
What can you do to increase the performance of an embedded system?
-
. How a flash memory can be Read, Erased, or Programmed? Explain the steps involved.
-
List any four applications of KNN. Explain with Example
-
Explain Demings quality principles? with Example
-
According to GAAP, which method should be used to recordthe acquisition of a fixed asset? A) Historical cost B) Fair market value C) Weighted average cost D) First in, First out (FIFO) E) Last in,...
-
What is the difference between adsorption and absorption?
-
Jason and Mary are married taxpayers in 2012. They are both under age 65 and in good health. For this tax year, they have a total of $41,000 in wages and $500 in interest income. Jason and Mary's...
-
Yolanda earns $112,000 in 2012. Calculate the FICA tax that must be paid by: Yolanda:.....................Soc.Sec..................$__________...
-
Kent Pham, CPA, is a 45-year-old single taxpayer living at 169 Trendie Street, La Jolla, CA 92037. His Social Security number is 865-68-9635. In 2012, Kent's W-2 as the controller of a local...
-
This exercise considers the data described in the Section 13.2.2 ratemaking classification example using data in Table 13.3 Table 13.3 . a. Fit a gamma regression model using a log-link function with...
-
This exercise considers data from the Medical Expenditure Panel Survey (MEPS) described in Exercise 1.1 and Section 11.4. Our dependent variable consists of the number of outpatient (COUNTOP) visits....
-
Verify that the Tweedie distribution is a member of the linear exponential family of distributions by checking equation (13.9). In particular, provide an expression for \(S(y, \phi)\) (note that...
Study smarter with the SolutionInn App