Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
hub-courses
python_one_week_4_biologists_solutions
Commits
15a2a611
Verified
Commit
15a2a611
authored
Mar 11, 2019
by
Bertrand NÉRON
Browse files
🐛
remove comment specific to python2
parent
271c4860
Changes
1
Hide whitespace changes
Inline
Side-by-side
source/Data_Types.rst
View file @
15a2a611
...
...
@@ -40,23 +40,16 @@ Use the Python interpreter to check your answers. ::
8.5
>>> height / 3
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.
>>> # if you need precision you need to use Decimal. But operations on Decimal are slow and float offer quite enough
t
precision
>>> # 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 ap
p
roximation.
>>> # 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
>>> # Euclidian division
>>> 2 / 3
>>> 2 /
/
3
0
>>> # float division
>>>
float(2)/float(3)
>>>
2 / 3
0.6666666666666666
>>> # decimal division
>>> from decimal import Decimal
>>> a = Decimal(2)
>>> b = Decimal(3)
>>> a / b
Decimal('0.6666666666666666666666666667')
>>> 1 + 2 * 5
11
Exercise
...
...
@@ -76,9 +69,7 @@ after that, you can use ``math.pi`` everywhere in the file like this::
>>>
>>> #do what you need to do
>>> 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
:linenos:
:language: python
...
...
@@ -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?
The ``find`` method give the index of the first occurence or -1 if the substring is not found.
So we can not determine the occurence of a site only with the find method.
We will see how to do that when we learn looping and conditions.
The ``find`` method give the index of the first occurrence or -1 if the substring is not found.
So we can not determine the occurrences of a site only with the find method.
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
...
...
@@ -381,14 +373,8 @@ use sv40 sequence to test your function.
>>>
>>> sequence = fasta_to_one_line(sv40)
>>> 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
'the sv40 is 5243 bp length and have 40.80% gc'
: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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment