ubuntu2004
Kernel: Python 3 (system-wide)
Exercises 14.1
Loop through the following DNA sequence using range()
and print each base.
In [2]:
Out[2]:
A
C
G
G
A
T
A
T
A
T
A
T
A
T
G
C
C
C
G
T
A
A
T
A
T
A
T
A
G
C
G
Exercises 14.2
Modify your code so that it prints all quintuplets (5 consecutive bases) of dna_seq
. For example, the first few quintuplets are "ACGGA", "CGGAT", "GGATA", etc.
Hint: This is slightly different to the example in Notebook 14 in which the step size was 3. Here we want a step size of 1.
In [9]:
Out[9]:
ACGGA
CGGAT
GGATA
GATAT
ATATA
TATAT
ATATA
TATAT
ATATA
TATAT
ATATG
TATGC
ATGCC
TGCCC
GCCCG
CCCGT
CCGTA
CGTAA
GTAAT
TAATA
AATAT
ATATA
TATAT
ATATA
TATAG
ATAGC
TAGCG
AGCG
GCG
CG
G
Exercises 14.3
Modify your code so that it counts all occurrences of the quintuplet "TATAT".
In [11]:
Out[11]:
4
Exercises 14.4
Use range()
to calculate the sum of all the numbers in the following list. Print the sum.
In [13]:
Out[13]:
16552
Exercises 14.5
Use range()
to simultaneously loop through the following two lists. Add each pair of numbers and print them.
In [14]:
Out[14]:
16.2
6.9
-19.1