Commit 4d17374f authored by Blaise Li's avatar Blaise Li
Browse files

Move comment to the correct place.

parent 561097d6
Pipeline #58079 passed with stages
in 12 seconds
......@@ -47,25 +47,22 @@ Exercise
>>> id(x)
139950507563632
With mutable object like ``list`` when we mutate the object the state of the object is modified.
With mutable object like ``list``, when we mutate the object, the state of the object is modified.
But the reference to the object is still unchanged.
So in this example we have two ways to access to the list [1,2] if we modify the state of the list itself.
but not the references to this object, then the 2 variables x and y still reference the list containing
[1,2,3,4].
compare with the exercise on string and integers:
Comparison with the exercise on strings and integers:
Since list are mutable, when ``+=`` is used the original list object is modified, so no rebinding of *x* is necessary.
We can observe this using *id()* which give the memory address of an object. This address does not change after the
Since lists are mutable, when ``+=`` is used, the original list object is modified, so no rebinding of *x* is necessary.
We can observe this using *id()* which gives the memory address of an object. This address does not change after the
``+=`` operation.
.. note::
even the results is the same there is a subtelty to use augmented operator.
in ``a operator= b`` python looks up ``a``s value only once, so it is potentially faster
than the ``a = a operator b``.
Even the results are the same, there is a subtelty to use augmented operator.
In ``a operator= b`` opeeration, Python looks up ``a``'s value only once, so it is potentially faster
than the ``a = a operator b`` operation.
compare ::
Compare ::
x = 3
y = x
......@@ -95,6 +92,10 @@ and ::
:figclass: align-center
In this example we have two ways to access to the list ``[1, 2]``.
If we modify the state of the list itself, but not the references to this object, then the two variables ``x`` and ``y`` still reference the list containing
``[1, 2, 3, 4]``.
Exercise
--------
......@@ -198,7 +199,7 @@ first implementation:
python -i codons.py
>>> codons = all_codons()
:download:`codons.py <_static/code/codons.py>` .
:download:`codons.py <_static/code/codons.py>`.
second implementation:
""""""""""""""""""""""
......@@ -367,7 +368,7 @@ Compute the 6 mers occurences of the sequence above, and print each 6mer and it'
aaatat .. 2
:download:`kmer.py <_static/code/kmer.py>` .
:download:`kmer.py <_static/code/kmer.py>`.
bonus:
......@@ -404,7 +405,7 @@ Print the kmers by ordered by occurences.
ccagtg .. 3
:download:`kmer_2.py <_static/code/kmer_2.py>` .
:download:`kmer_2.py <_static/code/kmer_2.py>`.
Exercise
......@@ -435,7 +436,7 @@ pseudocode:
>>> print rev_comp(seq)
tgtgttgcgctcacgaaccagaccaagagcatccactggactttctcctctcagagcccactggccagccatgttgccgt
:download:`rev_comp.py <_static/code/rev_comp.py>` .
:download:`rev_comp.py <_static/code/rev_comp.py>`.
other solution
......@@ -524,7 +525,7 @@ and the 2 dna fragments: ::
enz_2 = enz_filter(enzymes, dna_2)
enz1_only = set(enz_1) - set(enz_2)
:download:`enzymes_1.py <_static/code/enzyme_1.py>` .
:download:`enzymes_1.py <_static/code/enzyme_1.py>`.
with this algorithm we find if an enzyme cut the dna but we cannot find all cuts in the dna for an enzyme. ::
......@@ -565,7 +566,7 @@ The code must be adapted as below
:linenos:
:language: python
:download:`enzymes_1_namedtuple.py <_static/code/enzyme_1_namedtuple.py>` .
:download:`enzymes_1_namedtuple.py <_static/code/enzyme_1_namedtuple.py>`.
Exercise
--------
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment