Vice President Mondale was nearing the end of a final campaign swing through Pennsylvania today when he was confronted directly with some of the reasons for the erosion of President Carter's support in this key primary state.

It came in the form of a question from a student at Scranton Central High School.

"In 1976," the young man said, "Jimmy Carter promised to curb inflation, never to deceive the American people and to reach out to those people. However, inflation has never been higher, many Americans were deceived by the recent vote at the United Nations and the president has remained in Washington for 170 days now and we have no results, because our people are still in Iran."

"Why," the questioner concluded, "should the people of this nation give him another chance?"

No one is certain how Pennsylvania Democrats will answer that question in Tuesday's primary between Carter and Sen. Edward M. Kennedy, a contest that now appears so close that both sides are openly nervous.

The Carter camp believes that the president's slide has stopped, offering hope for a narrow victory, while Kennedy staffers wonder whether their man's comeback is enough. With a large undecided vote still being recorded by campaign pollsters, predictions of victory are couched in cautious terms.

"I sense a slight upturn, but it's going to be close," said Bob Casey, Carter's state co-chairman.

Kennedy ended two exhausting weeks of Pennsylvania campaigning today, blasting away at Carter's economic policies to speeches at the eastern and western ends of the state.

At a colorful rally in the heart of downtown Philadelphia, Kennedy told thousands of lunch-hour listeners that Tuesday's presidential primary election is their chance to add Carter's name to the unemployment rolls.

"Jimmy Carter says that the recession that we're facing . . . is going to be a mild one," Kennedy shouted in a rasping, gravelly voice born of long campaign days.

"Well, let's hope it's a really mild one. We hope that only one person is going to lose his job, and that that's going to be Jimmy Carter."

Kennedy argued again that Carter's effort to fight inflation through high interest rates and reductions in federal social programs flouts the "proudest traditions" of the Democratic Party.

Tonight Kennedy carried the same message to Washington, Pa., a steel-making, coal-mining city south of Pittsburgh on the state's western edge.

The Philadelphia rally, a heavily promoted event complete with bands, balloons and clouds of confetti, was designed as a grand finale to Kennedy's 14 days of campaigning here. It drew a crowd for that seemed to number between 10,000 and 20,000, plus hundreds of people who pokes their heads out the windows of surrounding office buildings.

At stake in the primary are 126 delegates to the Democratic convention, to be chosen in proportion to the popular vote, with another 59 delegates to be selected next month by the state Democratic committee.

For Kennedy, however, Pennsylvania means more than a large bloc of delegates. It is the first of the remaining large, industrial state primaries on which he is basing his uphill effort to overtake Carter and win the nomination.

A Kennedy victory here could breathe some life into that longshot strategy; a defeat could all but demolish it.

Alluding to this before a modest crowd at a Carter campaign breakfast this morning in Pittsburgh, Mondale appealed to Pennsylvania Democrats to "get this fight behind us."

The latest findings of Carter's pollster, Patrick Caddell, showed the president's decline in support had stopped in the last two days.

They also showed that voter concern over foreign policy issues and the possibility of a Kennedy win here are combining to hurt the Massachusetts senator, according to aides to Mondale.

Throughout the day, Mondale defended the president's record, particularly administration aid to the steel industry, and accused Kennedy of being "a candidate who discovered the problems of the steel industry three weeks ago."

He told his questioner at Scranton Central High School that inflation was largely due to foreign oil price increases but was being dealt with, that the U.N. blunder over the question of Israel's settlements policy was a "misunderstanding," and that "no one has had more heartache" over the Iran crisis or has tried harder to solve it than Carter.

Mondale ended his two-day Pennsylvania campaign swing by visiting a textile plant and an ethnic neighborhood in Philadelphia. Carter campaign officials concede Philadelphia to Kennedy, but hope to hold down the margin and win statewide with a strong showing in the central part of the state.

While the vice president was in Philadelphia, the Carter campaign headquarters in the city was being occupied through much of the day in a protest by about 25 Puerto Rican tenants of a government assisted housing project who face eviction.