Posts

Showing posts with the label format
Programe is: # #     Dynamic precision results printing # a =17 i = 0 answer = 'y' while answer == 'y' or answer =='Y':     alfa = input('decimal point is:')     FORMAT = " ' Result is:, '%." + alfa + "f'"     print('format is:', FORMAT)     print(FORMAT %a)     answer = input(' to continue type y or Y: ')     i = i +1 print(' Final running!', i, 'problems') Results are: Python 3.10.2 (v3.10.2:a58ebcc701, Jan 13 2022, 14:50:16) [Clang 13.0.0 (clang-1300.0.29.30)] on darwin Type "help", "copyright", "credits" or "license()" for more information. ======== RESTART: /Users/ionivan/Documents/Dynamic precisionPrinting.py ======== decimal point is:1 format is:  ' Result is:, '%.1f'  ' Result is:, '17.0'  to continue type y or Y: y decimal point is:2 format is:  ' Result is:, '%.2f'  ' Result is:, '17.00'  to con...

Formated print

PYTHON programe is: # #   Formated print # X = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] Y = [[1, 2, 3],      [4, 5, 6],      [7, 8, 9]] a = 7 b = 15 print(" a= %5d b= %5d" %(a, b)) nr = len(X) i = 0  while i < nr:     print("%5d" %(X[i]))     i = i +1 print('List was printed ', ' ') row_number = len(Y) column_number = len(Y[0]) i = 0  while i < row_number:     j = 0      while j < column_number:         print("%5d " %(Y[i][j]), end =" ")         j = j+1     print(" " )     i = i +1 print('List of list (matrix) was printed ', ' ')  Results are: Python 3.10.2 (v3.10.2:a58ebcc701, Jan 13 2022, 14:50:16) [Clang 13.0.0 (clang-1300.0.29.30)] on darwin Type "help", "copyright", "credits" or "license()" for more information. ============== RESTART: /Users/ionivan/Documents/FormatedPrint.py ==============  a=     7 b=...