Skip to content
Snippets Groups Projects
Verified Commit 15a2a611 authored by Bertrand  NÉRON's avatar Bertrand NÉRON
Browse files

:bug: remove comment specific to python2

parent 271c4860
No related branches found
No related tags found
No related merge requests found
...@@ -40,23 +40,16 @@ Use the Python interpreter to check your answers. :: ...@@ -40,23 +40,16 @@ Use the Python interpreter to check your answers. ::
8.5 8.5
>>> height / 3 >>> height / 3
4.0 4.0
>>> # one of the operand is a float (2.0 or height) then python pyhton perform afloat division but keep in mind that float numbers are aproximation. >>> # one of the operand is a float (2.0 or height) then python pyhton perform a float division but keep in mind that float numbers are approximation.
>>> # if you need precision you need to use Decimal. But operations on Decimal are slow and float offer quite enought precision >>> # if you need precision you need to use Decimal. But operations on Decimal are slow and float offer quite enough precision
>>> # so we use decimal only if wee need great precision >>> # so we use decimal only if wee need great precision
>>> # Euclidian division >>> # Euclidian division
>>> 2 / 3 >>> 2 // 3
0 0
>>> # float division >>> # float division
>>> float(2)/float(3) >>> 2 / 3
0.6666666666666666 0.6666666666666666
>>> # decimal division
>>> from decimal import Decimal
>>> a = Decimal(2)
>>> b = Decimal(3)
>>> a / b
Decimal('0.6666666666666666666666666667')
>>> 1 + 2 * 5
11
Exercise Exercise
...@@ -76,9 +69,7 @@ after that, you can use ``math.pi`` everywhere in the file like this:: ...@@ -76,9 +69,7 @@ after that, you can use ``math.pi`` everywhere in the file like this::
>>> >>>
>>> #do what you need to do >>> #do what you need to do
>>> math.pi #use math.pi >>> math.pi #use math.pi
**Hint**: the volume of a spher with radius 5 is **not** 392.7 !
.. literalinclude:: _static/code/vol_of_sphere.py .. literalinclude:: _static/code/vol_of_sphere.py
:linenos: :linenos:
:language: python :language: python
...@@ -257,9 +248,10 @@ for the enzymes which have a recognition site can you give their positions? :: ...@@ -257,9 +248,10 @@ for the enzymes which have a recognition site can you give their positions? ::
is there only one site in sv40 per enzyme? is there only one site in sv40 per enzyme?
The ``find`` method give the index of the first occurence or -1 if the substring is not found. The ``find`` method give the index of the first occurrence or -1 if the substring is not found.
So we can not determine the occurence of a site only with the find method. So we can not determine the occurrences of a site only with the find method.
We will see how to do that when we learn looping and conditions. We can know how many sites are present with the ``count`` method.
We will see how to determine the site of all occurrences when we learn looping and conditions.
Exercise Exercise
...@@ -381,14 +373,8 @@ use sv40 sequence to test your function. ...@@ -381,14 +373,8 @@ use sv40 sequence to test your function.
>>> >>>
>>> sequence = fasta_to_one_line(sv40) >>> sequence = fasta_to_one_line(sv40)
>>> gc_pc = gc_percent(sequence) >>> gc_pc = gc_percent(sequence)
>>> report = the sv40 is {0} bp length and have {1:.2%} gc".format(len(sequence), gc_pc) >>> report = "the sv40 is {0} bp length and have {1:.2%} gc".format(len(sequence), gc_pc)
>>> print report >>> print report
'the sv40 is 5243 bp length and have 40.80% gc' 'the sv40 is 5243 bp length and have 40.80% gc'
:download:`gc_percent.py <_static/code/gc_percent.py>` . :download:`gc_percent.py <_static/code/gc_percent.py>` .
::
gc_pc = float(sv40_sequence.count('g') + sv40_sequence.count('c')) / float(len(sv40_sequence))
"the sv40 is {0} bp lenght and have {1:.2%} gc".format(len(sv40), gc_pc)
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment