Potato is a root vegetable that can be eaten baked, fried, cooked, in soups, etc. (see more detailed info on preparation). Even though this vegetable can last for many months if kept in a dark and cool environment, it is still often found in food dumpsters - usually because it has bruises, some green parts, or started to rot after contact with water. If it is a latter case, it is usually recommended not to take such a potato. If potato's "defect" is a simple bruise, you can take these potatoes home and simply cut off these usually small "defects".
About green spots on potatoes: these indicate the presence of a rather harmful toxin called solanine. The green is actually a chlorophyll which is not bad for you at all; however, the chlorophyll indicates that the potato has been exposed to sunlight, or was kept in a very warm or very cold temperature. So, a natural toxin in the potato becomes concentrated at harmful levels. Eating large amount of green potatoes will cause vomiting, headache, diarrhea, and can even cause a paralysis of the central nervous system. What you can do is when you see patches of green in your potatoes as you peel them, cut out the green parts entirely and discard them; some recommend not to take green potatoes at all. When storing potatoes, avoid direct sunlight: always keep them in a cool, completely dark place. (More info: link 1 | link 2)