Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Can I delete single quotes in string matrix display
#1
Hi all ! I should like to have a pretty display of the string matrix. Is it possible ??

print("MULTIPLICATION TABLE")


def pause():
    input("Press ENTER to continue")


M = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
     [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
     [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
     [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
     [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
     [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
     [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
     [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
     [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
     [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]
print("New values in the matrix")
for i in range(len(M)):
    for j in range(len(M)):
        M[i][j] = i * j

print("Print the matrix 'M', beginning with a 0, display beginning by a 1"
for row in M[1:]:  # display beginning by item number 1, not number 0
    print(row[1:])  # display beginning by item number 1, not 0

pause()
print("This multiplication_table 'N' is a matrix beginning by a 1")
N = []
for x in range(1, 10):
    new_row = []
    for y in range(1, 10):
        new_row.append(x * y)
    N.append(new_row)
print(N)
pause()
print("Now a display of the same, row by row")
for row in N[0:]:  # begin by number 0
    print(row[0:])  # begin by number 0
pause()
print("The following 'P' is a matrix")
P = [[x * y for y in range(1, 10)] for x in range(1, 10)]
print(P)

for x in range(len(P)):
    print(P[x])
pause()
print("New 'P'  in a square")
for i in range(len(P)):
    for j in range(len(P)):
        if len(str(P[i][j])) == 1:
            P[i][j] = " " + str(P[i][j])
        else:
            P[i][j] = str(P[i][j])

for x in range(len(P)):
    print(P[x])


pause()
print("\nNow action between the 2 matrixes 'M', beginning with a 0, and 'N' with a 1 ")
print([M[row][col] * N[row][col] for row in range(5) for col in range(5)])
print("second action")
print([[M[row][col] * N[row][col] for row in range(5)] for col in range(5)])

exit()
Quote
#2
>>> from pprint import pprint

>>> pprint(matrix)
[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Quote
#3
Thank you. This is new useful information for me. Below my thread, there is a thread of 'sparkz_ alot': remove apostrophes in list
sparkz_alot which gives information to me too.
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Python convert multi line into single line formatted string karthidec 2 552 Dec-23-2019, 12:46 PM
Last Post: karthidec
  Select single letters from string based on separate string Jpen10 3 580 Dec-15-2019, 01:21 PM
Last Post: Jpen10
  Delete minimum occurence in a string RavCOder 10 468 Nov-12-2019, 01:08 PM
Last Post: RavCOder
  Print string in a single line RavCOder 8 419 Nov-08-2019, 09:45 AM
Last Post: perfringo
  Cannot Remove the Double Quotes on a Certain Word (String) Python BeautifulSoup soothsayerpg 5 1,315 Oct-27-2019, 09:53 AM
Last Post: newbieAuggie2019
  [split] capitalize dict keys for display in string newbieAuggie2019 3 433 Oct-10-2019, 10:50 AM
Last Post: perfringo
  String being broken up into single characters ammorgan 1 572 Dec-31-2018, 07:06 AM
Last Post: Gribouillis
  How to display <IPython.core.display.HTML object>? pythopen 2 20,637 Oct-17-2018, 06:22 PM
Last Post: pythopen
  Word co-occurrence matrix for a string (NLP) JoeB 2 7,944 Feb-27-2018, 11:21 PM
Last Post: Larz60+
  replace string inside double quotes jmpatx 10 8,585 Apr-26-2017, 05:27 AM
Last Post: nilamo

Forum Jump:


Users browsing this thread: 1 Guest(s)