Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/python3
- # --- Constants ---
- mtypes = ['b','v','p', '']
- # --- Code ----
- while True:
- print("Select matrix type:\n1. bmatrix\t2. vmatrix\t3. pmatrix\t4. matrix\n")
- stype = input('> ')
- try:
- stype = int(stype)
- if stype > 4 or stype < 1:
- print("Please input a number from 1 to 4\n")
- continue
- except:
- print("Please input a number from 1 to 4\n")
- continue
- break
- stype = mtypes[stype - 1]
- while True:
- print ("\nInput the amount of matrix lines")
- try:
- lines = int(input('> '))
- if lines < 1:
- print("Please input a positive number\n")
- continue
- except:
- print("Please input a positive number\n")
- continue
- break
- while True:
- print ("\nInput the amount of matrix columns")
- try:
- columns = int(input('> '))
- if columns < 1:
- print("Please input a positive number\n")
- continue
- except:
- print("Please input a positive number\n")
- continue
- break
- latex = "\\begin{" + stype + "matrix} "
- print("Iteration started. Input the correspondent LaTeX of the elements for each line:")
- for i in range(0, lines):
- print("Line " + str(i+1) + ":")
- for j in range(0, columns):
- print("\tElement " + str(j+1) + ": ", end="")
- element = input()
- latex += element
- if j != columns-1:
- latex += " & "
- print("\n")
- if i != lines-1:
- latex += " \\\\ "
- print("\n\n")
- latex += " \\end{" + stype + "matrix}"
- print("Process ended. LaTeX: " + latex)
- input()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement