1. Write a Python program that declares two lists. a. Set the values in the first...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
1. Write a Python program that declares two lists. a. Set the values in the first list to [-3, 0, 3, 6] by initializing on the line where the list is declared. Print the elements of the list using fields 3 characters wide for each element. b. Build the first list up to [-3,0,3, 6] by starting with an empty list and using a counting loop whose loop index variable goes from 1 to 4 and finding a formula that converts the loop variable into the needed values. Use the append member function of the list to add to the list. (Spend some time thinking about this, as it may be useful later.) Print the list using fields 5 characters wide for each element. c. Declare an empty list. Use a loop and, within it, prompt the user for integer values (they needn't be the ones from parts a and b) and add each value the user enters into the first array directly. After each number is entered, ask the user whether or not to continue. After the user chooses not to enter more numbers, print the list. d. Use a loop to fill a second array with the values from the first array from part c) in reverse order. Print the second array. Hint: Get the code to work without worrying about the print formatting first. 1. Write a Python program that declares two lists. a. Set the values in the first list to [-3, 0, 3, 6] by initializing on the line where the list is declared. Print the elements of the list using fields 3 characters wide for each element. b. Build the first list up to [-3,0,3, 6] by starting with an empty list and using a counting loop whose loop index variable goes from 1 to 4 and finding a formula that converts the loop variable into the needed values. Use the append member function of the list to add to the list. (Spend some time thinking about this, as it may be useful later.) Print the list using fields 5 characters wide for each element. c. Declare an empty list. Use a loop and, within it, prompt the user for integer values (they needn't be the ones from parts a and b) and add each value the user enters into the first array directly. After each number is entered, ask the user whether or not to continue. After the user chooses not to enter more numbers, print the list. d. Use a loop to fill a second array with the values from the first array from part c) in reverse order. Print the second array. Hint: Get the code to work without worrying about the print formatting first.
Expert Answer:
Answer rating: 100% (QA)
Solution a list1 3 0 3 6 for e in list1 print3dformate e... 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
-
Q1. You have identified a market opportunity for home media players that would cater for older members of the population. Many older people have difficulty in understanding the operating principles...
-
You are required to write a Python program that will manage character (heroes and villain) information. Character (hero and villain) information will be stored in a text file that will be read in...
-
In an organization that has high employee satisfaction, ______. Multiple choice question. customer interactions are forced and scarce employee turnover is high more positive interactions take place...
-
Real estate investment in college towns continues to promise good returns (The Wall Street Journal, September 24, 2010). With rents holding up, this is good news for investors but the same cannot be...
-
Question 1 Below, you are provided with the domestic demand and supply curves for palm trees. Use this diagram to answer all parts of this question. Price $1,400 $1,200 $1,000 $800 $600 $400 $200 50...
-
Under what conditions is an auditor most likely to confirm payables?
-
Phoenix Company's 2015 master budget included the following fixed budget report. It is based on an expected production and sales volume of 15,000 units. Required 1. Classify all items listed in the...
-
The viscosity of water can be determined from Equation (3) given in the lab handout where A, B, and C are constants, and Tis temperature in degrees K. If temperature is measured to be 300 K with an...
-
Details of a company's insurance policy are shown below: Premium for year ended 31 March 2008 paid April 2007 Premium for year ending 31 March 2009 paid April 2008 $25,920 $28,800 What figures should...
-
Crane, Poole & Schmidt is a bustling law firm located in Massachusetts. Concerned with the amount of time employees were "social not-working" during firm hours, Shirley Schmidt, the managing partner,...
-
While helping an astronomy professor, you discover a binary star system in which the two stars are in circular orbits about the system's center of mass. From their color and brightness, you determine...
-
An attractive central force exerted on a particle of mass \(m\) causes the particle to travel in a bound orbit. The orbit is clliptical with semimajor axis \(a\), and the force has magnitude...
-
Which of the following statements is false? a. If an intangible asset has a finite life, it should be amortized. b. The amortization period of an intangible asset can exceed 20 years. c. Goodwill is...
-
A meteoroid passes through a position in space where its speed is very small relative to Earth's and it is at a perpendicular distance of 19 Earth radii above Earth's surface. The meteoroid is moving...
-
A space probe can be either launched at escape speed from Earth or transported to a "parking orbit" above Earth and then launched. (a) If the parking orbit is \(180 \mathrm{~km}\) above Earth's...
-
Coronado Burrito Inc. sells franchises to independent operators throughout the northwestern part of the United States. The contract with the franchisee includes the following provisions. 1. The...
-
Consider the sections of two circuits illustrated above. Select True or False for all statements.After connecting a and b to a battery, the voltage across R1 always equals the voltage across R2.Rcd...
-
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?...
-
Bea Jones (age 32) moved from Texas to Florida in December 2011. She lives at 654 Ocean Way, Gulfport, FL 33707. Bea's Social Security number is 466-78-7359 and she is single. Her earnings and income...
-
Bill and Guilda each own 50 percent of the stock of Radiata Corporation, an S corporation. Guilda's basis in her stock is $25,000. On July 31, 2012, Bill sells his stock, with a basis of $40,000, to...
-
Use the Chart screen (Chart ) to generate historical prices of a selected stock and its call and put options with different expirations and expiration. Select a period in which the options were...
-
Use the Chart screen (Chart ) to generate historical prices for the S\&P 500 spot, and call and put options on the index with different expirations and expiration. Select a period in which the...
-
Suppose just prior to going ex-dividend, XYZ stock is trading at \(\$ 65\) and is expected to go ex-dividend with a dividend expected to be worth \(\$2.50\) on the ex-dividend date. What advice would...
Study smarter with the SolutionInn App