``````

In :

'A'

``````
``````

Out:

'A'

``````
``````

In :

'ACGT'

``````
``````

Out:

'ACGT'

``````
``````

In :

st = 'ACGT'

``````
``````

In :

len(st) # getting the length of a string

``````
``````

Out:

4

``````
``````

In :

'' # empty string (epsilon)

``````
``````

Out:

''

``````
``````

In :

len('')

``````
``````

Out:

0

``````
``````

In :

import random
random.choice('ACGT') # generating a random nucleotide

``````
``````

Out:

'C'

``````
``````

In :

random.choice('ACGT') # repeated invocations might yield different nucleotides

``````
``````

Out:

'C'

``````
``````

In :

random.choice('ACGT') # repeated invocations might yield different nucleotides

``````
``````

Out:

'T'

``````
``````

In :

random.choice('ACGT') # repeated invocations might yield different nucleotides

``````
``````

Out:

'A'

``````
``````

In :

random.choice('ACGT') # repeated invocations might yield different nucleotides

``````
``````

Out:

'G'

``````
``````

In :

# now I'll make a random nucleotide string by concatenating random nucleotides
st = ''.join([random.choice('ACGT') for _ in range(40)])
st

``````
``````

Out:

'GTCACATAATGCTGTAGATTAAGCGAGAAGACCTTAGGTC'

``````
``````

In :

st[1:3] # substring, starting at position 1 and extending up to but not including position 3
# note that the first position is numbered 0

``````
``````

Out:

'TC'

``````
``````

In :

st[0:3] # prefix of length 3

``````
``````

Out:

'GTC'

``````
``````

In :

st[:3] # another way of getting the prefix of length 3

``````
``````

Out:

'GTC'

``````
``````

In :

st[len(st)-3:len(st)] # suffix of length 3

``````
``````

Out:

'GTC'

``````
``````

In :

st[-3:] # another way of getting the suffix of length 3

``````
``````

Out:

'GTC'

``````
``````

In :

st1, st2 = 'CAT', 'ATAC'

``````
``````

In :

st1

``````
``````

Out:

'CAT'

``````
``````

In :

st2

``````
``````

Out:

'ATAC'

``````
``````

In :

st1 + st2 # concatenation of 2 strings

``````
``````

Out:

'CATATAC'

``````