Strings .edu
Strings
Genome 559: Introduction to Statistical
and Computational Genomics
Prof. James H. Thomas
Strings
? A string is a sequence of characters.
? In Python, strings start and end with single or double
quotes (they are equivalent but they have to match).
>>> s = "foo"
>>> print s
foo
>>> s = 'Foo'
>>> print s
Foo
>>> s = "foo'
SyntaxError: EOL while scanning string literal
(EOL means end-of-line)
Defining strings
? Each string is stored in the computer¡¯s
memory as a list (array) of characters.
>>> myString = "GATTACA"
myString
computer memory (7 bytes)
How many bytes are needed to store the human genome? (3 billion nucleotides)
Accessing single characters
?
You can access individual characters by using indices in square brackets.
>>> myString = "GATTACA"
>>> myString[0]
'G'
>>> myString[2]
'T'
>>> myString[-1]
Negative indices start at the
'A'
end of the string and move left.
>>> myString[-2]
'C'
>>> myString[7]
Traceback (most recent call last):
File "", line 1, in ?
IndexError: string index out of range
Accessing substrings
>>> myString = "GATTACA"
>>> myString[1:3]
'AT'
>>> myString[:3]
'GAT'
>>> myString[4:]
'ACA'
>>> myString[3:5]
'TA'
>>> myString[:]
'GATTACA'
notice that the length of the
returned string [x:y] is y - x
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- strings lists sets dictionaries and files 4 1 strings
- strings ncert
- strings and pattern matching purdue university
- using python in labeling and field calculations
- lecture 5 strings
- string manipulation based on cbse curriculum class 11
- algorithms linear and binary search
- python strings rxjs ggplot2 python data persistence
- python 3 beginner s reference cheat sheet http www
- introduction to the burrows wheeler transform and fm index