You asked
Which pentax k camera should I buy first to use a used 50mm f 1 8 for portraits?
The guide can't name a Pentax K body for you to buy first. It doesn't cover Pentax K cameras, so it can't say which ones suit this lens or what they cost. What it can tell you is how your used lens will behave.
The Pentax smc DA 50mm f/1.8 is made for APS-C sensors, has autofocus and uses the Pentax K mount. Look for an APS-C Pentax K body, since the lens is built for that sensor size.
For portraits, the lens frames like a classic 75-80mm portrait lens on APS-C, as the portraits guide explains. That gives flattering proportions from a comfortable distance, and f/1.8 blurs the background. It isn't stabilised, so in dim rooms keep your shutter speed high enough to avoid blur.
Since you already have the lens, spend the rest of your budget on the body and a second lens or accessories. The first camera guide suggests spending roughly as much on lenses as on the body, and it recommends a spare battery and a decent memory card, because mirrorless cameras use batteries quickly.
If you later move to full frame, the Pentax smc FA 50mm f/1.4 is listed for full-frame sensors, but the DA lens won't serve that purpose.
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}.