Python Forum
Can I delete single quotes in string matrix display
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()
Reply


Messages In This Thread
Can I delete single quotes in string matrix display - by sylas - Jul-22-2017, 08:05 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Check if two matrix are equal and of not add the matrix to the list quest 3 820 Jul-10-2023, 02:41 AM
Last Post: deanhystad
  How to display <IPython.core.display.HTML object>? pythopen 3 45,921 May-06-2023, 08:14 AM
Last Post: pramod08728
  Need help on how to include single quotes on data of variable string hani_hms 5 2,014 Jan-10-2023, 11:26 AM
Last Post: codinglearner
  python sql query single quote in a string mg24 1 1,054 Nov-18-2022, 08:01 PM
Last Post: deanhystad
  Delete multiple comments with a single API call (facebook) Ascalon 0 2,313 Dec-04-2021, 08:33 PM
Last Post: Ascalon
Question [SOLVED] Delete specific characters from string lines EnfantNicolas 4 2,204 Oct-21-2021, 11:28 AM
Last Post: EnfantNicolas
  How to multiply a matrix with herself, until the zero matrix results peanutbutterandjelly 3 3,353 May-03-2021, 06:30 AM
Last Post: Gribouillis
  Parse String between 2 Delimiters and add as single list items lastyle 5 3,347 Apr-11-2021, 11:03 PM
Last Post: lastyle
  Remove single and double quotes from a csv file in 3 to 4 column shantanu97 0 6,976 Mar-31-2021, 10:52 AM
Last Post: shantanu97
  Two types of single quotes Led_Zeppelin 2 1,907 Mar-15-2021, 07:55 PM
Last Post: BashBedlam

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020