President Carter sought yesterday to soften the political impact of the anti-inflation measures he has imposed by announcing steps to cushion certain segments of the economy from the gathering recession.

In a nationally televised news conference five days before Pennsylvania's primary election, the president also predicted a general improvement in economic conditions after a few more months of bad news.

He asserted that the recession will be "mild and short" and predicted a dramatic drop in the inflation rate, from about 18 percent to about 10 percent annually, within a few months.

Carter mentioned steps he said would aid four sectors -- farmers, the housing industry, automobile workers and consumers -- in dealing with the economic downturn that finally seems to have arrived.

Some of those steps, taken earlier in the day, included:

A decision by the Federal Reserve Board to make up to $3 billion available to lend to small businesses and farmers at reduced interest rates.

An announcement by the Housing and Urban Development Department that it will help builders obtain loans on unsold houses and will extend subsidies for low-income buyers at a cost of about $160 million. [Details on Page C1].

The president outlined these steps in the second half of a lengthy statement opening the news conference. Its central theme, clearly aimed at growing voter discontent with the economy, was an expression of sympathy for those hardest hit, coupled with an appeal for patience before the arrival of promised better times ahead.

While noting that interest rates have begun to edge down, Carter warned that "we will continue to see bad news on inflation" for a few months. But in his message of hope, he added:

"After that, starting early this summer, the chances are very good for a sizable drop in the inflation rate. We should have much smaller increases in energy prices this year compared to last year, and mortgage interest rates should no longer be rising. Indeed, I hope to see them fall.

"There are not quick and easy answers, but there is no reason for fear or despair. Our programs are good, our American economy is strong and our people are united and determined to meet these challenges together."

In response to a question, the president said his actions and announcements -- particularly those involving the Iranian crisis -- have not been designed to influence the primaries. But the limited economic steps he announced yesterday, and his prediction of an economic upturn soon, seemed clearly timed for the final primary races, beginning with next week's in Pennsylvania.

The auto industry has been particularly hard hit by the economic slowdown that the administration sought to induce to combat inflation. In the last few days, both General Motors Corp. and Ford Motor Co. announced plant closings or cutbacks that will result in layoffs for 27,000 workers.

To offset this, Carter said the administration has budgeted more than $1 billion extra in trade adjustment assistance "to tide the auto workers over until new jobs can be found for them." However, he did not mention that this is an ongoing, automatic program or that the additional expenditures over his budget estimates resulted from failure by the Labor Department until recently to calculate the amount of this aid that auto workers are eligible for because of rising auto imports.

The president said he opposes a proposal by the United Automobile Workers to limit automobile imports, asserting that this would drive up the price of domestically produced cars and force American consumers to buy "large and inefficient gas guzzlers which they do not want."

But he said the administration was seeking to persuade foreign automakers to build plants in the United States and suggested that such policies prompted the announcement by Nissan Motor Co. yesterday that it will build a $300 million plant to manufacture pickup trucks in the United States.

The news conference, dominated by Carter's announcement of new sanctions against Iran and his comments on the economy, contained few overtly political subjects. But the president used the platform to full political advantage, as evidenced by his unusually lengthy 10-minute opening statement.

The statement was so long that, ahead of time, White House press secretary Jody Powell told Frank Cormier, the Associated Press reporter who traditionally ends news conferences with his "thank you" to the president, that he could let the session run more than the customary 30 minutes and Carter wouldn't mind.

As a result, the news conference took more than 40 minutes.

Asked about charges by his political rivals that he has timed announcements on the Iranian crisis to help him politically, Carter noted that primary elections are held virtually every week and added:

"I have never designed the announcement of an action to try to color or modify the actions of voters in a primary. These occurrences are too serious for our nation . . . I do not make, and have not made, and will not make decisions or announcements concerning the lives and safety of our hostages simply to derive some political benefits from them."

The president also said the primary results so far, while not "a complete endorsement of what I have done," are an indication "that the American people are fairly well satisfied."

Carter conceded that his prediction of an 8-percentage-point drop in the annual inflation rate within a few months is based on "two big 'ifs'" -- confining this year's rise in the price of oil imports to about 20 percent, and a reduction of about 2 percentage points in home mortgage rates. But he said these developments are not "beyond the realm of expectation" if there is "a concerted commitment on the part of the American people to the program that we have outlined."

"I have a very good feeling about the future this year, about controlling inflation and reduced interest rates," the president said.