diff --git a/source/Data_Types.rst b/source/Data_Types.rst index 68b7c638491ce85da1f9fb4e5148ae692594b4f0..da465530920bf3aeab9e4e757deeba67c56c1777 100644 --- a/source/Data_Types.rst +++ b/source/Data_Types.rst @@ -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 enought 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 approximation. + >>> # 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