Create the following vectors efficiently using loops (i.e. without vectorization). See if you can find more...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Create the following vectors efficiently using loops (i.e. without vectorization). See if you can find more than 1 solution. (20 pts) (a) A = [1, 3, 5, 7, 9, ...] up to n = 10 terms. Modify your code to work for n = 100. (b) B = [1, 2, 4, 8, 16, 32, ...] up to n = 10 terms. Modify your code to work for n = 100. (c) C= [1, 0.1, 0.01, 0.001, 0.0001, ...] up to n = 10 terms. Modify your code to work for n = 20. (d) D= [1, -1, 1, -1, 1, -1, ...] up to n = 10 terms. Modify your code to work for n = 100. (e) E= [0, 1/2, 2/3, 3/4, 4/5, 5/6, ...] up to n = 10 terms. Modify your code to work for n = 100. Create the following vectors efficiently using loops (i.e. without vectorization). See if you can find more than 1 solution. (20 pts) (a) A = [1, 3, 5, 7, 9, ...] up to n = 10 terms. Modify your code to work for n = 100. (b) B = [1, 2, 4, 8, 16, 32, ...] up to n = 10 terms. Modify your code to work for n = 100. (c) C= [1, 0.1, 0.01, 0.001, 0.0001, ...] up to n = 10 terms. Modify your code to work for n = 20. (d) D= [1, -1, 1, -1, 1, -1, ...] up to n = 10 terms. Modify your code to work for n = 100. (e) E= [0, 1/2, 2/3, 3/4, 4/5, 5/6, ...] up to n = 10 terms. Modify your code to work for n = 100.
Expert Answer:
Answer rating: 100% (QA)
Here are the solutions to create the vectors efficiently using loops Vector A Python def createvectorAn Creates a vector containing the odd numbers from 1 to n A for i in range1 n 1 2 Aappendi return ... 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
-
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...
-
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...
-
1. Give 3 examples of well-defined sets. 2. Name two subsets of the set of whole numbers using both the listing method and the rule method. 3. Let B [1, 3, 5, 7, 9}. List all the possible subsets of...
-
One of the highest airports in the world is located in La Paz, Bolivia. Pilots prefer to take off from this airport in the morning or the evening, when the air is quite cold? Explain.
-
Gold Star Printing made its required tax deposits. However, it filed its thirdquarter Form 941 on December 10, after receiving notice from the missing forms IRS. What is the failure to file penalty...
-
Diageo North America, Inc., the owner of the Bulleit brand family of whiskeys, sued competitor W.J. Deutsch & Sons Ltd. for allegedly infringing upon the trade dress of Diageos Bulleit bottles....
-
(Entries for Conversion, Amortization, and Interest of Bonds) Volker Inc. issued $2,500,000 of convertible 10-year bonds on July 1, 2010. The bonds provide for 12% interest payable semiannually on...
-
1. Write an integral using cylindrical coordinates that represents the volume between the surfaces z=x+ y and z = 6-x - y.
-
The Royal Seas Company runs a three-night cruise to the Caribbean from Port Canaveral. The company wants to run TV ads promoting its cruises to high-income men, high-income women, and retirees. The...
-
A refinery procures two types of crude oil: Type "A" and Type "B", and processing either type into finished fuel products. Type "A" costs $70 per barrel to procure and costs $1 to process per barrel,...
-
Write a small business case for nonlinear preemptive goal programming with two goals. Clearly define your objective function, constraints and decision variables. Give me a short solution for exam
-
Question 1 The following lots of a particular commodity were available for sale during the year: Beginning inventory First purchase Second purchase Third purchase Units 180 Unit Total Cost Cost 5 $10...
-
It was the end of the accounting period for Karen. Her company just wrapped up its busiest time of the year, as specialized laser-cut steel fire pits suddenly were a hot item. She was working on the...
-
UiTMPhone is a broadband service provider. Assume that UiTMPhone class for billing consists of the following data members ( ( attributes ) . ) . Define the complete UiTMPhone class definition with...
-
Write a script called pow.sh that is located in your workspace directory to calculate the power of two integer numbers ( ( e . . g . . a ^ ^ b ) ) ; where a and b are passed as parameters from the...
-
1. Mary and Pete have lived in a home from 1973 to 2020. They purchased the home for $180,000 and sold it for $560,000. Assume the couple has not used a section 121 exclusion before. How much will...
-
The registrar of a college with a population of N = 4,000 full-time students is asked by the president to conduct a survey to measure satisfaction with the quality of life on campus. The following...
-
Patty Bayan is a single taxpayer living at 543 Space Drive, Houston, TX 77099. Her Social Security number is 466-33-1234. For 2012, Patty has no dependents, and her W-2 from her job at a local...
-
Ray and Maria Gomez have been married 3 years. They live at 1610 Quince Ave., McAllen, TX 78701. Ray works for Palm Oil Corporation and Maria works for the City of McAllen. Maria's Social Security...
-
Steve Drake sells a rental house on January 1, 2012, and receives $130,000 cash and a note for $55,000 at 10 percent interest. The purchaser also assumes the mortgage on the property of $45,000....
-
Based on Exhibit 1, the execution cost for purchasing the 90,000 shares of BYYP is: A. \($60\),000. B. \($82\),500. C. \($127\),500. Robert Harding is a portfolio manager at ValleyRise, a hedge fund...
-
What type of algorithm should be used to purchase the XYZ shares given Hardings priority in building the XYZ position and his belief about potential price movements? A. Scheduled algorithm B. Arrival...
-
Which of Yellows statements regarding the trade implementation of non-equity investments is correct? A. Only Statement 4 B. Only Statement 5 C. Both Statement 4 and Statement 5 Robert Harding is a...
Study smarter with the SolutionInn App