At first sight, toilets seem quite simple: you have a waste pipe going through the floor and a tank of water up above (called a cistern) waiting to flush into it when someone pushes a button or pulls a lever or a chain. Most flush toilets are purely mechanical: pull the chain and the cistern empties through the force of gravity, washing the bowl clean for use again. They are literally mechanical because they flush and refill using levers inside—and levers are examples of what scientists call simple machines.
There's a little bit more to toilets than this. When you flush, the cistern has to refill automatically from a kind of faucet on the side and the refilling operation has to last just long enough to fill the tank without making it overflow. The "hole in the ground" is more sophisticated than it looks as well. You may have noticed that toilets always have a little water in the bottom of them; even when you flush them, they never empty completely. Some water is always trapped in a big curved pipe at the base of the toilet known as the S-bend (or S-trap). This little bit of water effectively seals off the sewage pipe beneath it, stopping germs and bad smells from coming up into your bathroom.