Build Punnett squares in code, cross plants for one and two traits, count the ratios, and simulate many crosses to see chance at work.
3 lessons, about 1 h 50 min3 simulations11 problems3 practice questionsPython in every lesson
A Punnett square lists every way two gametes can meet. In code, a gamete is a letter and a genotype is a sorted pair of letters. A Counter of the four boxes gives the 1:2:1 ratio of genotypes and the 3:1 ratio of tall to short.
With two genes, each gamete carries one letter of each. itertools.product lists the four gametes of RrYy, and two of them meeting fill a 16-box square. Counting phenotypes gives Mendel's 9:3:3:1, and a test cross reveals a hidden genotype.
Real crosses are a matter of chance. random.choice picks one gamete from each parent, and a loop makes many offspring. For a few plants the share of short ones wanders far from 25 %; for thousands it settles near it. A bar chart compares observed with expected.
Log in to join the discussion.
Loading…