We frequently get new shooters looking into purchasing their first firearm, primarily for home defense.  This quick guide will give you a basic understanding of what is involved.  While this is by no means comprehensive, as we could probably write a thick book on the subject, it will give you some baselines for making some decisions and asking the right questions.

For home defense I recommend a carbine rifle, such as an AR-15. That may sound surprising, since most movies and media almost exclusively show the use of the "defensive handgun", but I'll explain why. First reason is that I find typical shooters to be about 10x more accurate with a rifle (e.g. the same shooting drill that you would do at 10 yards with a pistol can be done at 100 yards with a rifle, and produce the same results in terms of speed and accuracy). The rifle also carries more ammunition, and has enhanced lethality, yet studies have shown that the bullets produce no more structure penetration than a 9mm handgun (this is because the AR-15's bullet is very small but very fast, so after penetrating a couple walls, it has often broken up into pieces and/or slowed down considerably).

Shotguns are another popular home defense gun, though I do not recommend them as your first choice, because they have a low capacity, are difficult and time consuming to reload, and generally require a higher degree of skill and training to use effectively and efficiently. At the typical distances available within a home, the shot pattern spread from a tactical shotgun (18.5" barrel) is only about "baseball size", so it really doesn't allow the shooter to neglect shooting accurately (see article here for pictures).

Roughly speaking, handguns are "compromise weapons", sacrificing a great deal of combat power for increased portability. Within the home, the handgun is at a disadvantage to a rifle in most ways, and being light weight and concealable are not pragmatically beneficial.  If you desire to also use your new firearm for concealed carry, then the pistol is your obvious only choice. If you really have your heart set on a pistol for home defense already, I recommend a semi-auto model that is carried and proven by law enforcement or military personnel. Pistols are the most difficult firearms to shoot accurately, requiring the most skill and training on marksmanship. Most semi-auto pistols (as opposed to revolvers) are fairly easy to reload and manipulate - comparable to a carbine rifle, and easier than a shotgun.

As far as cost, I like to use the analogy of a car. While there are cheap and expensive cars available, we could probably agree that a "typical car" costs in the range of $20k-40k. Similarly, a shotgun will cost $300-500, a pistol $400-700, and a carbine rifle $500-1100.

You should also expect to purchase accessories, for a new gun, and/or as a new shooter. I recommend that you own a total of at least 6 magazines for each gun, to make target practice and training easier and more enjoyable (so that you will do it more often). Reloading one magazine, over and over is not fun. Plus, you never know when they will stop making your firearm, the magazines, or you won't be able to get them for some other reason. Expect magazines for rifles to cost $15-30 each, and pistols $25-35 each - buy good quality OEM magazines. Most rifles come with 1 magazine, and pistols come with 1-3, depending on model and manufacturer. You'll also want hearing protection, $15-50 each, ballistically-rated safety glasses, $8-20 each, and cleaning kit / BoreSnake, $25 (See: 10 Gun Cleaning Tips article). You may also want a gun case ($25-100), ammo can ($20), magazine loader ($35), targets ($5-10), and ammo ($0.40-$0.75 per round, for practice ammo, in boxes of 20 for rifles, and 50 for pistols).

Training varies based on your chosen firearm, skill level, and use goals. Generally, we charge about $150/day for our various courses, when we can get several students in them at once. Private/custom instruction is usually more, because we aren't able to get the "economy of scale" of having several students attend. You can look at our courses, and see if any of them seem appealing to you. My guess is that you'll be looking at the NRA Basic courses for a rifle, pistol, or shotgun. Those courses start from ground zero, teach how the firearms and ammunition function, build safe gun handling skills, develop solid shooting fundamentals, and test (written and live fire) to get an NRA certificate (that can be used for concealed carry license here in Colorado). We are certified NRA instructors for rifle, pistol, shotgun, reloading, and range safety officer, and some other ratings.

Hopefully this gives you a basic understanding of what will be involved in purchasing and getting trained with a new home defense gun.  If you have any other questions, please leave them in the comments section below.