The following code segment is a short program that copies the elements from an integer list...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
The following code segment is a short program that copies the elements from an integer list into another integer list and adds 1 to each element. It then prints each element of both lists, the one without modifications, and the one that has 1 added to every element. There are 4 errors. Find and fix these errors. Hint: remember how to copy a list without pointing to the same list in memory. 1. values= [1,2,3,4,5] 2. newValues = values 3. for i in range (len (values) +1): values[i] +=1 4. print("Old Value at index {} is: {} ".format(i, newValues[i])) print("New Value at index () is: () \n".format(i, newValues[i])) 5. 6. The following code segment is a short program that copies the elements from an integer list into another integer list and adds 1 to each element. It then prints each element of both lists, the one without modifications, and the one that has 1 added to every element. There are 4 errors. Find and fix these errors. Hint: remember how to copy a list without pointing to the same list in memory. 1. values= [1,2,3,4,5] 2. newValues = values 3. for i in range (len (values) +1): values[i] +=1 4. print("Old Value at index {} is: {} ".format(i, newValues[i])) print("New Value at index () is: () \n".format(i, newValues[i])) 5. 6.
Expert Answer:
Answer rating: 100% (QA)
Step 1 Changes are done in above code 1 newValuesvaluescopy 2 for i in rangelenvalues 3 printOld Value at index is formati valuesi 4 printNew Value at ... 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 civil engineering questions
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
The Crazy Eddie fraud may appear smaller and gentler than the massive billion-dollar frauds exposed in recent times, such as Bernie Madoffs Ponzi scheme, frauds in the subprime mortgage market, the...
-
Assignment 5: Hash Table implementation andconcordance There are three parts to this assignment. In the first two parts,you will complete the implementation of a hash map and aconcordance program. In...
-
A fast-food chain randomly attaches coupons for prizes to the packages used to serve french fries. Most of the coupons say Play again, but a few are winners. Seventy-five percent of the coupons pay...
-
Exercise 8 of Chapter l includes data on the Japanese exchange rate (EXRJ) by month. On the basis of a time-series plot of these data and the autocorrelation structure of EXRJ, would you say the data...
-
5. The ball leaves the ground at angle = 60. Determine the initial velocity if the ball is to just 0 clear the 3-m tall fence. Use g = 9.8 m/s. Note: to keep thing simple, you may assume h = 3 is...
-
White Top Rafters uses the direct write-off method to account for bad debts. Record the following transactions that occurred during the year: May 3 Nov 8 Dec 10 Provided $970 of services to Sam...
-
Suppose that the market can be described by the following three sources of systematic risk with associated risk premiums. Factor Risk Premium Industrial production (I) ........ 6% Interest rates (R)...
-
Common stock is valued at $1,000,000 and costs $0.20. Bonds are valued at $850,000 and cost $0.04. Preferred stock is valued at $500,000 and costs $0.06. The tax rate is 40%. What is the pre-tax WACC?
-
Using the approach described in Example 10.6, classify first record in the worksheet Records to Classify in the Excel file Credit Risk Data using the k-NN algorithm for k = 1 to 5. Use only Checking,...
-
Describe advantage and one disadvantage of electronic records. Explain how HIPAA protects the privacy and patients' confidentiality as it relates to electronic medical records.
-
Question: Equipment was purchased for $36,000 by issuing a 5-year note payable to the seller for $20,000, the balance paid in cash. The note pays 5% interest annually on January 1 st. For expense...
-
A piano plays a note with a frequency of 7 7 7 H z . If the speed of sound in air on this particular day is 3 4 3 m s what is the period and wave length?
-
Florida Kitchens produces high-end cooking ranges. The costs to manufacture and market the ranges at the company's volume of 3,000 units per quarter are shown in the following table: Unit...
-
A treasurer of an Australian bank issues a 1-year, AUD$1 million CD at 2.7 percent annual interest to finance a Canadian investment. The treasurer invests C $1.307 million in 2-year fixed-rate...
-
Written Assignment: Answer each below using correct grammar, punctuation and complete sentences. 1. Identify and discuss four basic steps in a risk management program. 2. Define concepts of...
-
Who set forth the following "equation for value: "The value of any stock, bond or business today is determined by the cash inflows and outflows--discounted at an appropriate interest rate--that can...
-
Fred Farmer needs to prepare a balance sheet for his bank. He spent the day getting the following information. Fred needs your help to build a balance sheet and evaluate it. The information was...
-
Diane is a single taxpayer who qualifies for the earned income credit. Diane has two qualifying children who are 3 and 5 years old. During 2012, Diane's wages are $17,100 and she receives dividend...
-
Ken paid the following amounts for interest during 2012: Qualified interest on home mortgage...........................................$4,700 Auto loan...
-
Ann hires a nanny to watch her two children while she works at a local hospital. She pays the 19-year-old nanny $125 per week for 48 weeks during the current year. a. What is the employer's portion...
-
The rotor shown in Fig. 9.44 (a) is balanced temporarily in a balancing machine by adding the masses \(m_{1}=m_{2}=90 \mathrm{~g}\) in the plane \(A\) and \(m_{3}=m_{4}=90 \mathrm{~g}\) in the plane...
-
A turbine rotor is run at the natural frequency of the system. A stroboscope indicates that the maximum displacement of the rotor occurs at an angle \(229^{\circ}\) in the direction of rotation. At...
-
The cylinders of a four-cylinder in-line engine are placed at intervals of \(300 \mathrm{~mm}\) in the axial direction. The cranks have the same length, \(100 \mathrm{~mm}\), and their angular...
Study smarter with the SolutionInn App