'A'
'A'
'ACGT'
'ACGT'
st = 'ACGT'
len(st) # getting the length of a string
4
'' # empty string (epsilon)
''
len('')
0
import random
random.choice('ACGT') # generating a random nucleotide
'C'
random.choice('ACGT') # repeated invocations might yield different nucleotides
'C'
random.choice('ACGT') # repeated invocations might yield different nucleotides
'T'
random.choice('ACGT') # repeated invocations might yield different nucleotides
'A'
random.choice('ACGT') # repeated invocations might yield different nucleotides
'G'
# now I'll make a random nucleotide string by concatenating random nucleotides
st = ''.join([random.choice('ACGT') for _ in range(40)])
st
'GTCACATAATGCTGTAGATTAAGCGAGAAGACCTTAGGTC'
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
'TC'
st[0:3] # prefix of length 3
'GTC'
st[:3] # another way of getting the prefix of length 3
'GTC'
st[len(st)-3:len(st)] # suffix of length 3
'GTC'
st[-3:] # another way of getting the suffix of length 3
'GTC'
st1, st2 = 'CAT', 'ATAC'
st1
'CAT'
st2
'ATAC'
st1 + st2 # concatenation of 2 strings
'CATATAC'