Measuring your actual OG as mmb said is best, but you can estimate it before you brew it. It won't be precise, but it'll be close enough for estimating pitching rate.
You calculate the gravity contribution from your various fermentable sources in points per pound per gallon (PPG), which is a measure of amount of fermentable sugars in a gallon of wort containing a pound of given extract. It varies according to the source of the extract, since different grains and LME and DME produce varying amounts of fermentable sugars.
Different brands of DME and LME have different degrees of fermentability, but in general DME is about 45 PPG and LME is about 36. You'll commonly see claims of 44 to 46 for DME and 35 to 37 for LME. Unless the brands you buy provide a laboratory analysis (unlikely), the best you can do is approximate.
If the fermentables in your recipe consists of 6 pounds of DME, then:
(6 lb x 45 points) / 5 gallons = 54.
Add the SG of water, which is 1.000, to this to get your estimated OG of 1.054.
It gets more complicated when you derive your wort from a grain mash because your efficiency at extracting sugars will be the unique result of all the variables in your mash process.
While this is all very fascinating, don't let it get in the way of getting your first couple of batches going. You are going to end up spending countless hours reading and studying all the finer points of brewing, and you are going to need to have some homebrew handy to wash it all down with.