how to write makefile for python?

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

Was this solution helpful to you?

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

Find solution

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.