03.lecture

BIOS1100 H17 uke 3_澳门葡京手机版app下载

BIOS1100 H17 uke 3

Lex Nederbragt







Ukens forelesning

  • noen praktiske ting
  • begrepsforståelse kapittel 2
  • utvalgte øvelser
  • nytt stoff uke 3

Læringsmål uke 2

Biologi
  • kunne forklare hvordan bakterier formerer seg
  • kunne de forkjellige faser i bakteriell vekst
Programmering
  • kunne visualisere et enkelt datasett
  • kunne lagre visualiseringen i en fil
  • kunne last inn et enkelt datasett fra fil
  • kunne bruke lister i python
Matematikk
  • kunne beskrive en lineær figur i rommet matematisk
  • være i stand til å utlede vekstrate og doblingstid for eksponesiell bakterievekst

En del praktiske ting

  • obliger: tidspunkter
  • celler i notebook
  • hva er en python pakke?

Exercise 1: List slicing (1)

Fill in the blank to achieve the desired output

bases = ["A", "C", "G", "T"]
AT_basepair = [bases[_], bases[_]]
print(AT_basepair)

[A,T]
  1. A, T
  2. 0, 3
  3. 1, 4
  4. 0, -1
Answer. Option 2 and 4

Solution.

  1. It is the index of the desired element that you need, and not the desired element.
  2. Correct - the first element's index is 0 and the last element's index is 3.
  3. Elements A and T are the desired elements. A is in the first place and index of the first element is 0 and not 1. Therefore, index of the last element is not 4, but 3.
  4. Correct - index of the first element, which is A, is 0 and no matter how long the list is, element with index -1 is always the last element of the list.

Exercise 2: List slicing (2)

list = [0, 2, 4, 6, 8, 10]

Which of the following would give the list [2, 4, 6]?

  1. list[1:3]
  2. list[1:4]
  3. list[2, 4, 6]
  4. list[0:3]
Answer. Option 2

Solution.

  1. This gives: [2, 4]. When indexing , elment with index "to" is not included.
  2. Correct. Element "2" has index 1 and element "6" has index 3. Since element with index 4 is not included in slicing, we will get elements with indexes 1, 2 and 3, which gives [2, 4, 6].
  3. This gives TypeError. You can have list[2], list[4] or list[6] in general (in this case list[6] does not exist since our list has only 6 elements - last element has index 5), or in slice form, which is list[from:to], but list[a, b, c] cannot be used.
  4. This gives: [0, 2, 4]. Look at the solution above (point 2).

Exercise 3: List slicing (3)

What is the output of following program?

list1 = [1, 2, 3, 4, 5, 6]
list2 = list1[-2:]
print(list2)
  1. [5, 6]
  2. [1, 2, 3, 4, 5]
  3. [5]
  4. [6]
Answer. Option 1

Solution.

Exercise 4: List slicing (4)

What is the output of following code?

list1 = [10, 12, 16, 23, 54, 3]
print(len(list1[1:5]))
  1. 4
  2. 5
  3. 3
  4. 1
Answer. 1

Solution. Function len() counts the number of elements in a given list, array, dictionary, etc (more about arrays and dictionaries in later chapters). In this case, [1:5] takes into account the second element (index 1) and second last element (index 4). It does not take into account element with index 5, but one before that. Therefore, the answer is 4.

Exercise 5: Logarithms

a) What is \( \log_2(2^3) \)

  1. 1
  2. 2
  3. 3
  4. 8
Answer. 3

Solution. By definition, the logarithm with base \( x \) of \( x^n \) is \( n \), or \( \log_x (x^n) = n \)

Utvalgte øvelser

  • Exercise 3: Death phase: decline rate
  • Exercise 7: Oldest people in the world
  • Exercise 8: Volume of a sphere and Bergmann's rule

Læringsmål uke 3

Matematikk

  • kunne lage og implementer et enkelt eksponesiell vekst modell
  • kunne sammenligne resulater fra modellen med eksperimentelle data
  • kunne forklare begrensninger med eksponesiell vekst modellen
Programmering
  • Numpy arrays
  • for løkker

Parring

Vi begynner med 1 student som står mens resten sitter. Vi gjør følgende:

  1. hver runde finner hver student som står en partner
  2. alle nye partnere skal stå opp også
Etter hvor mange runder tror du at alle står?

--> Mentimeter

Hvorfor modellering

  • simulering
  • predikering
  • billig og trygt eksperiment
  • eksempler
    • klimamodeller
    • sykdomsspredning
    • torskebestander

Hvordan modellering

  • matematisk modell
    • sett med regler
  • implementering
    • beregningsmodell
    • algoritme

Matematisk modell





Matematisk modell

After each time step, we have twice as many bacteria. $$ \begin{equation} E_n = 2E_{n-1}. \label{_auto1} \end{equation} $$





Implementering

Python

  • Numpy arrays
    • som lister, men mer egnet for mattematikk
  • for løkker
    • jobbe effektivt med lister, arrays mm

Repetisjon

Rule of three.

In programming, there is a rule of thumb called ''the rule of three''. It states that if a task has to be repeated three times or more, we should automate it.

  • manuell repetisjon er tidskrevende
  • manuell repetisjon kan lett bli en feilkilde

For loops

numbers_list = [7, 2, 4, 3]

print(numbers[0])
print(numbers[1])
print(numbers[2])
print(numbers[3])

Eller

numbers_list = [7, 2, 4, 3]

for number in numbers_list:
    print(number)

Volume of a sphere and Bergmann's rule

Calculate the ratio \( \frac{Surface Area}{Volume} \), for the following radiuses:

0.5, 1, 1.5, 2, 2.5, 3, 3.5 and 4 meter.

Store the results in two different lists called radiuses and ratios.

Start the ratios list as an empty list:

ratios = []

Then add the ratios each time you calculate them using the ratios.append() function.

Growth model for E. coli

After each time step, we have twice as many bacteria. $$ \begin{equation} E_n = 2E_{n-1}. \label{_auto2} \end{equation} $$





Growth model for E. coli

$$ \begin{align} E_n &= 2E_{n-1}, \label{_auto3}\\ t_n &= t_{n-1} + \Delta t, \label{_auto4} \end{align} $$

for n in range(1, N):
    E[n] = 2*E[n-1]
    t[n] = t[n-1] + delta_t

Python versus matte

$$ \begin{equation} x = x + 1. \label{_auto5} \end{equation} $$

x = 12
x = x + 1
print(x)

13

Publisert 4. sep. 2017 17:13 - Sist endret 4. sep. 2017 17:14