Posts

Showing posts with the label print()

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=...
Three values a, b and c are entered from the keyboard. The program shows several variables for setting the minimum and maximum value. The PYTHON program is: # Minimum and Maximum element choice between a, b, c a = input('First number:') b = input('Second number:') c = input('Third number:') minim = a if (minim > b):     minim = b if (minim > c):     minim = c print('Minimum from a, b,  c is:', minim) if(a < b):     if(a < c):         minim = a     else:         minim = c elif (b < c):     minim = b else:     minim = c print('Minimum from a, b,  c is:', minim) minim = a if (a < b) else b minim = minim if (minim < c) else c print('Minimum from a, b,  c is:', minim) minim = (a if(a<c) else c) if(a<b) else (b if(b<c) else c) print('Minimum from a, b,  c is:', minim) # Alegere element maxim dintre a, b, c maxim = a if (maxim < b): ...

First PYTHON program

The first program written in PYTHON gathers two numbers entered from the keyboard and displays the result. The program instructions are: #    First program a = input('First number:') b = input('Second number:') c = int(a) + int(b) print('Result c is:', c) IDLE Shell 3.10.2 afișază: 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/Primul program.py ============= First number:4 Second number:11 Result c is: 15 (March, 21, 2022) 

PYTHON Language Programming

PYTHON language programming is: - flexible, - portable, - easy, - free, - accessible,  - intuitive, - versatile, - universal,  - convenient, - ordinary,  - common. PYTHON programming language has taken over the best of all the programming languages before it. It is simple, efficient, dense and attractive. The input() statement is used to enter the data. The print() instruction is used to present the results. Variable names are constructed the same as all other programming languages: - the first character is required a letter, - the other characters are letters, numbers or underscores, - uppercase letters differ from lowercase letters, - any words other than the reserved words of the PYTHON language. - the length of the name does not exceed 31 characters. The string is preceded and followed by quotation marks. The string is preceded and followed by an apostrophe. Correct variable names: a i j temp Triangle surface_cercle  volume_cube Name_P...