Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
python_one_week_4_biologists_solutions
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hub-courses
python_one_week_4_biologists_solutions
Commits
15a2a611
Verified
Commit
15a2a611
authored
6 years ago
by
Bertrand NÉRON
Browse files
Options
Downloads
Patches
Plain Diff
remove comment specific to python2
parent
271c4860
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
source/Data_Types.rst
+11
-25
11 additions, 25 deletions
source/Data_Types.rst
with
11 additions
and
25 deletions
source/Data_Types.rst
+
11
−
25
View file @
15a2a611
...
@@ -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 ap
p
roximation.
>>> # if you need precision you need to use Decimal. But operations on Decimal are slow and float offer quite enough
t
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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment