A candle timer as a mechanical if statement

True, this video shows a mechanical switch — but it also demonstrates something far deeper and more interesting.

---

You can think of this simple mechanical switch as a code function, even though in this case its implementation uses a candle and a ring.

The function is essentially a simple `if` statement.
As long as the value representing the candle's height is greater than the value representing the ring's position, the candle keeps burning.
Once the value representing the height becomes equal to or less than the ring's position, the candle is extinguished.

---

We tend to think of computers, software, and code as abstract concepts.
In reality, they represent logical structures that can be implemented through entirely mechanical means — water pumps or ropes, for instance.

This candle could just as well be made of pixels on a screen, say in a video game, and the logic governing its burning and extinguishing would be identical.
Thinking about objects and code logic the same way we think about the physical world will go a long way toward helping us write effective, efficient code.

---

As a simple example, consider the following code:

```python
candle_height = 10
ring_position = 3
candle_status = True

while candle_status:
print(f"Candle burns. Height: {candle_height}")
candle_height -= 1

if candle_height <= ring_position:
print("Ring claps down and extinguishes the flame!")
candle_status = False
```

A candle timer as a mechanical if statement