You asked
Pentax hd da 20 40mm f 2 8 4 ed limited dc wr vs tamron 17 50mm f 2 8?
I don't have a page for the Tamron 17-50mm f/2.8, so I can't compare the two fairly from here. I can tell you about the Pentax, though. The Pentax HD DA 20-40mm f/2.8-4 ED Limited DC WR is an APS-C zoom for Pentax K bodies. It has a small metal barrel and is weather-resistant. On APS-C it frames roughly like 30-60mm on full frame. It isn't stabilised, and its aperture narrows from f/2.8 to f/4 as you zoom in, so it's darker at the long end than a constant f/2.8 zoom. It suits Pentax shooters who want something compact and well built.
If you're choosing a first standard zoom, the Lenses page sets out what to look for, and Your first camera explains how to split the budget.
Written by Claude from this site's pages.