top of page

Calculating Ratios

Mendel

Peas

Phenotypes

Inheritance

Dominant & Recessive

Ratios 1

Ratios 2

Checkpoint

Human Health

Summary

Let’s say we want to write a piece of code to determine if a given sample shows a 3:1 phenotype ratio. We can store each of the observed numbers of pea phenotypes in a variable, and then divide these values to calculate the phenotype ratio. Then, to determine if this ratio is equal to 3, we can deploy an if statement.

1 # Imagine Mendel observed 9 green and 3 yellow peas

2 greenPeas = 9

2 yellowPeas = 3

3 ratio = greenPeas/yellowPeas

4 if ratio == 3:

5    print("There is an exact 3 : 1 phenotype ratio!")

If you flipped a coin 100 times and observed 57 heads and 43 tails, would you assume that the coin was rigged? Probably not. In the same way, phenotypic ratios can vary slightly around the ‘true’ or expected value due to random chance.

 

In a real scientific experiment, we do not expect to observe an exact 3 : 1 phenotype ratio due to random noise in the system. For example, if you flip a fair coin twice, you will most often observe one head and one tail, but that is not necessarily true. If you continue to flip your coin hundreds of times, you are increasingly likely to observe approximately 50% heads and 50% tails. In real life, we would need to modify the above code to accommodate an approximate 3 : 1 ratio, rather than an exact 3 : 1 ratio. Let's say that we will allow ratios as low as 2.7 and as high as 3.3 (plus or minus 10% of 3) to be called a 3 : 1 ratio. Then, our if statement would look look like the following:

1 # Imagine Mendel observed 340 green and 125 yellow peas

2 greenPeas = 340

2 yellowPeas = 125

3 ratio = greenPeas/yellowPeas

4 if ratio > 2.7 and ratio < 3.3: # and combines 2 conditions

5    print("There is about a 3 : 1 phenotype ratio!")

6 else

7    print("There is not a 3 : 1 phenotype ratio!")

bottom of page