Beans, corn, bell peppers, peas,
eggplant, pumpkins, cucumbers, squash, and tomatoes are all fruits.
That is because, botanically speaking, fruits are the part of
flowering plants that contain the seeds and are the means by which
such plants disseminate those seeds. So even nuts are fruits.
Grains, which are really over-sized seeds are also fruits.
Also, botanically speaking, vegetables are all the other parts of
the plant, including the leaves (e.g. lettuce and spinach), roots
(e.g. potatoes and carrots), bulbs (e.g. onions and garlic), flowers
(e.g. artichokes, broccoli, and cauliflower), and stems (e.g.
rhubarb and celery). Also, botanically speaking, some spices, such
as allspice and chilies, are fruits.
If it is from a plant and has seeds (or would have seeds if it
wasn't genetically engineered or cultivated to not have them, as
with seedless grapes), it is a fruit; if it does not naturally have
seeds, it is a vegetable.
The reason we learn peppers, corn, and cucumbers are vegetables and
are found in the veggie section is due to tradition. Culinary
traditions (with no scientific value) tell us the part of the plant
we are eating does not matter, taste does. Fruits are generally
sweet tasting and vegetables are more savory and less sweet. Fruits
are also typically served as part of dessert or as snacks, and
vegetables are often part of the main dish.
Scientific classification system makes a clear dividing line between
fruits and vegetables, while the culinary system of classification
is much more ambiguous. Not to be outdone, The United States
Supreme Court entered the debate and gave a legal verdict about
whether a tomato should be classified as a vegetable or a fruit.
They decided unanimously, in Nix vs. Hedden, 1883, that a tomato is
a vegetable, even though it is a botanical fruit. I use a much
more simple method - If I like it, it's a fruit, if I do not like
it, it's a vegetable.