Python – , , , . – . Python (, , , ) . – .
, . . Turbo Pascal Delphi. .
, Python : , , . . .
. ?
. . FOR.
Python . list . , .
, . Python FOR. , . . .
Python , . . :
- List1.append (x) – , .
- List1.extened (list2) – list2 list1. , extend .
- List1.insert (i,x) – i. , ( , append), .
- List1.remove (x) – . , . , ValueError (x not in list).
- List1.pop ([i]) – i. , . , , . . .
- List1.index (x, [start], [end]) – start end. . , 0. . . 0, – 1 . . , = [1.78487,5.575,7.364]. [0] = 1.78487, [1] = 5.575, [2] = 7.364.
- List1.count (x) – , . , , .
- List1.sort ([key = ]) – . Python . , .
- List1.reverse () – , . . , . .
- List1.copy () – .
? .
:
- Print – . Python 2.7 , Python 3 . , Python 2.7 : print « », kolichestvo ( -, – ). Python 3 : print (« », kolichestvo). .
- Len(list1) – Python .
- Min – , , .
- Max – .
- Sum – , , . , TypeError: unsupported operand type(s) for +: 'int' and 'str'.
- Help – . help (int) – , help (str) – , help (file) – , , , .
- Type – , . : >>> text_str = «» >>> type (text_str) >>> <type 'str'>
- in. , , .
. , Python . Turbo Pascal Delphi, , Python 3-4 .
, Python , immutable. , tuple. . . tuple . , – . . append, . , tuple.
tuple , . : tuple ("string") → ("s","t","r","i","n","g").
, Python . OS listdir. , Python 3 ( 2.7 ) os.listdir (path) path . .
1. . , . . . .
:
- List1 (. . ).
- .
- , , , (min<X<max).
- List2.
- List2 .
2. . , , , .
:
- 1. , . : while, len ().
- . , (, ). , , – , – .
- . . , , 0.
- . . , . . 2. : FOR. : , .
- . . . , .