A pistol is a handgun. The word may be used broadly to mean any handgun, or narrowly to mean only a magazine pistol, as distinct from a revolver.
In a magazine pistol, the cartridges are in a magazine, which is a metal or plastic box. The magazine is usually inside the handle of the pistol. When the pistol is fired, the empty cartridge pops out, and the next one comes up into position. The magazine is spring-loaded so it pushes the next bullet into place as the empty cartridge is ejected. For that reason pistols are sometimes called "semi-automatic". When the magazine runs out of cartridges, it can be reloaded by inserting more cartridges.