Shops are rooms where a trader buys and sells items. Some may have a collection, others may stick to one type(e.g. scrolls). The larger a trader room is, the bigger and more varied his collection becomes.
There is always one shop with a few variable items spawned in the smallest room in the village. Commonly, he's the first friendly creature to turn to if a battle becomes too much for you to handle, especially if you started as a low-strength class(eg. Alchemist or Sage). Simply hide behind the trader and throw objects at your pursuer.
Whenever you sell an item, it becomes immediately available to buy again, but at twice the price. Shops trade items at their neutral(+0) state when unidentified. For example, an unidentified potion of curing sells for $500, which is the cost of a neutral potion. However, It is entirely possible for that potion to be blessed or cursed. If you sell a trader an identified blessed potion of curing, the trader offers it later for sale at $750.
Identification is the key. It is better for identification to be one of the last learned skills if you plan to trade a lot, since any item being traded unidentified carries a possibility of being blessed/cursed. Also, the prices of certain types of rings(e.g. regeneration & locus mastery) or wands(e.g. annihilation & wishing) can skyrocket once identified. Keep in mind you can save before identification then load again to determine which items to keep(blessed or useful) and which to sell away(cursed or useless) as generic neutral items in their respective types, essentially cheating the unlucky trader for a few extra coins.
Among the items typically sold away to traders are non-metallic weapons/armor (e.g. war hammer & leather armor), bad food (e.g. mushrooms other than green), dead bodies you'd rather not eat (e.g. dregs or brown bats), bows and their respective ammo (unless you prefer projectiles to melee). You can also take the time-consuming yet rewarding approach of having a magician morph those items for you into more usable items.