Lab 02 · if / else

The Operon

This cell has a problem: milk sugar (lactose) is food it can't eat — until it builds a tool called lactase. So it carries a gene that says, in effect: "only build lactase IF lactose shows up." That's an if-statement. Nature wrote it about two billion years before we did, and it runs inside you right now. Let's run one ourselves.

the cell · membrane included
lactose in
0
energy
0

Milk in the environment

40

Sugar has to drift into the cell before the gene can see it. Biology is slow; CPUs are fast.

the program this cell runs, ~8× a second — watch the bright branch:

the_operon.js

          
⚡

What you're watching: the gene never changes — the input changes, and the output follows. Slide milk to zero and the gene goes dark. Flood the cell and it lights up. Every program you'll ever write has this same skeleton: read input → branch → output. You now understand if / else. E. coli agrees.

fun fact · this gene is why some people can't drink milk Most mammals switch the LAC gene off after infancy (it's expensive to keep running — you'll learn that lesson when your first program eats all the RAM). A few thousand years ago, some humans picked up a mutation in the gene's promoter — the on/off switch — that never quite turns it off. That one typo is why some adults drink milk and others regret it. One letter. Whole different lifestyle. Lab 3 is about that kind of switch.

So genes have on/off switches… and switches can be reconfigured:

Lab 3 · Epigenetics — same genes, different girl →