Announcement

Collapse
No announcement yet.

Pretty tables in Python

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Pretty tables in Python

    I am very new to programming so please explain with examples.

    I have a three dimensional array that I have filled, it started like this:

    a = [[[0 for depth in range(0)] for row in range(20)] for col in range(20)]

    Then I appended data to it as the calculations went on.

    The output I want is a 2 dimensional array, indexed by column and range, where the entries of depth (ranging zero entries to 7 or 8) are listed.

    Python does exactly what I want, but now I want to print it and look for the patterns I want by inspection. This needs a table that is not all over the place.
    All help is appreciated.

    For anyone really interested I am working on the 3x+1 problem.

  • #2
    don't know python

    Java code

    for (int depth=0; depth<20; depth++){
    System.out.println("Matrix "+depth);

    for(int row=0; row<20; row++){
    for (int col=0; col<20; col++)
    System.out.print(x[depth][row][col]+" ");
    System.out.println(" "");

    }//for row

    System.out.println(" "");
    System.out.println(" "");
    }//for depth


    The above assumes array has already been populated, that the array name is x, that the base indexes for dimensions start with 0 (range 0 to 19). The code will print 20 two-dimensional tables corresponding to depth=0, depth=1, depth=2, .., depth=19.
    Last edited by Toramana; 11-29-2010, 11:38 PM.

    Comment


    • #3
      Thanks.

      I ended up using a code that was already written by someone to get the exact output I needed .

      Comment

      Working...
      X