Python is a high-level universal language that can be extended and integrated. He, for example, is included in the application package as a tool for writing macros. This makes Python a smart choice for many programming tasks, large and not very, and not so good for a small number of computational tasks.
Where is better to use?
Python is ideal for projects requiring rapid development. It supports several programming paradigms, which is good for programs that require flexibility. And the presence of many packages and modules provides versatility and saves time.
– Python, « ». 1980- , , . .
, . , , .
Python .
Python . . . , C { } – . , , , Python. ? , , . .
, , . , , , . . , Python , , , . . , , , , .
. , . , . Python . , .
, , , , C ++, . , , , . .
, Python . , ( Java), , C.
Python 1989 ., . 1991 ., Usenet.
Python
Python, . Python 2.7 Python 3.5 , - , , .
«» , . Windows Python. python.org.
, Python, , , , .
, , () . Python. , . .
IDLE , . Python .
, , . :
, . .
, . , . Python .
Python , , >>>.
.
Python , , .
. , .
! Python , .
:
.
( , ) :
- >>> = [3,2]
- >>>
- [3, 2]
- >>> print
- [3, 2]
«print » , . , – :
- >>> x = "MyString"
- >>>
- "MyString"
- >>> print
- MyString
(, , ), , .
Message
:
- >>> class Message:
- ... pass
- ...
- >>> Message
- <class ___ main ___. Message at 0x58db0>
- >>> print Message
- __main __. Message
Python . ('), (") (''' """) . x:
Python . . . , . , , - (.), :
s[i]. , s [0] , s [1] , :
, "". :
- (capitalize, upper, lower, swapcase, title);
- (count);
- (encode, decode);
- (find, replace, rfind, index, rindex, translate);
- (startswith, endswith, isalnum, isalpha, isdigit, islower, isspace, istitle, isupper);
- (join, partition, rpartition, split, splitlines);
- (center, ljust, lstrip, rstring, rjust, strip, zfill, expandtabs).
Python:
Python , - . , . , , . , , Python. , – :
- >>> bases = ['A', 'C', 'G', 'T']
- >>> bases
- ['A', 'C', 'G', 'T']
- >>> bases.append('U')
- >>> bases
- ['A', 'C', 'G', 'T', 'U']
- >>> bases.reverse()
- >>> bases
- ['U', 'T', 'G', 'C', 'A']
- >>> bases[0]
- 'U'
- >>> bases[1]
- 'T'
- >>> bases.remove('U')
- >>> bases
- ['T', 'G', 'C', 'A']
- >>> bases.sort()
- >>> bases
- ['A', 'C', 'G', 'T']
. , , , 'U' . , remove() , , .
, remove(), Python , . , .
Python:
. Python. :
- len() – ;
- dir() – , ;
- list() – , - .
- >>> help(round)
- Help on built-in function round:
- round(...)
- round(number[, ndigits]) -> floating point number
.
,
Python- . def, ( ), , . . , . :
- >>> def transcribe(dna):
- ... """Return dna string as rna string."""
- ... return dna.replace('T', 'U')
- ...
- >>> transcribe('CCGGAAGAGCTTACTTAG')
- 'CCGGAAGAGCUUACUUAG'
transcribe, , . replace() . . :
- >>> def reverse(s):
- ... """Return the sequence string in reverse order."""
- ... letters = list(s)
- ... letters.reverse()
- ... return ''.join(letters)
- ...
- >>> reverse('CCGGAAGAGCTTACTTAG')
- 'GATTCATTCGAGAAGGCC'
reverse , , , . . join (), , . , , ('' "").
Python - ? , . (), (). -. . , .
- >>> basecomplement = {'A': 'T', 'C': 'G', 'T': 'A', 'G': 'C'}
- >>> basecomplement.keys()
- ['A', 'C', 'T', 'G']
- >>> basecomplement.values()
- ['T', 'G', 'A', 'C']
- >>> basecomplement['A']
- 'T'
, , . Python class, . , , .
, , Python. ? :
- . , Paint Shop Pro 8 .
- Python , .
- , , .
- .
- Python .