You asked

Pentax hd d fa 21mm f 2 4 ed limited dc wr vs pentax hd fa 31mm f 1 8 limited?

The two lenses cover different jobs. The Pentax HD D FA 21mm f/2.4 ED Limited DC WR is a wide, compact, weather-sealed prime. On full frame it frames like 21mm, which suits landscapes, interiors and street scenes where you need to fit a lot in. The Pentax HD FA 31mm f/1.8 Limited is a standard-to-short-tele view with a faster aperture. On full frame it frames like 31mm, and it gathers almost a stop more light than the 21mm.

For dim light, people, food or anything that moves, the 31mm is the better buy. The portraits guide explains why a moderate focal length and a wide aperture suit faces, and the aperture and background blur section shows how f/1.8 separates a subject from the background. Neither lens is stabilised, so for low light the extra speed matters more than stabilisation would.

For travel, architecture and landscapes, the 21mm is the one to take. Its f/2.4 is fast enough for most daylight work, and its weather sealing matters outdoors. It is also the more compact of the two.

Both lenses fit the Pentax K-1 and K-1 Mark II as full-frame bodies. On APS-C bodies such as the KP or K-3 Mark III, the 21mm gives roughly a 32mm view and the 31mm roughly a 46mm view, so the 31mm becomes a classic portrait length there. If you want one lens for everything, the first lenses guide suggests pairing a fast standard prime with a standard zoom.

This answer does not quote prices. Check each lens page for current figures before buying.

Written by Claude from this site's pages.

From these pages

This answer is for the question above. Each answer is written for the exact question in its address, so a question with its details in it (a budget, what you shoot, what you already have) gets an answer about those details. An answer draws on all 15 pages of the guide and its catalogue of 320 cameras and 1050 lenses. Another question gets its own answer at its own address, as words after /ask/. Or fill in your own: /ask/which-camera-for-{what-you-shoot}-under-{budget}-euros or /ask/which-lens-for-{what-you-shoot}-on-{your-camera}.