Reversing a 1-D array. Write a Python function that given an array A of numbers returns an array B that has t?
-
a. What should the output of the function be for A = {3, 2, 1, 5, 9}? b. Write the Python function. Include detailed comments. The name of the function should be def ReverseArray(A). B should be returned. c. Evaluate the Python function for arrays of length 1, 5, and 10. Report each input and output. I know A. its B = [9,5,1,2,3] And C will be simple once i can determine a working code, but everything I've tried turns up errors
-
Answer:
python already offers the "reversed" builtin, which allows you to reverse any iterable: >>> r=reversed([1,2,3]) >>> r <list_reverseiterator object at 0x1eb3290> >>> list(r) [3, 2, 1] >>> r = reversed("abcdefghi") >>> r <reversed object at 0x1eb3350> >>> list(r) ['i', 'h', 'g', 'f', 'e', 'd', 'c', 'b', 'a'] >>>
Sarah at Yahoo! Answers Visit the source
Other answers
So what do you expect us to do? You didn't present your code or even the errors. What I find is useful is to break the problem up into tiny steps, then work on just getting each little step correct. For instance, write a function that takes an array...and returns it. Doesn't do anything. Ok, now try the next step, and so on.
PoohBearPenguin
Related Q & A:
- Is there a tool where you give a list of things and it returns related words?Best solution by Web Applications
- Is it correct to extend a bean class and write a class which holds logic to populate the bean we extend?Best solution by stackoverflow.com
- How do I make a python web program that is on a ubuntu server allow access to the server?Best solution by Yahoo! Answers
- How to access a nested function from another nested function in javascript?Best solution by devarticles.com
- What is the difference between B.Tech I.T and C.S.E?Best solution by quora.com
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.