The fittingly named Ministry of National Guidance was taking no chances today with its difficult charges so before the visit to the ousted shah's palace came a visit to south Tehran's slums.

Before and after, rags and riches, virtue rewarded and vice chastized -- these were the themes which the most obtuse of foreign journalists understood even if they had not beem told about the slum part of the program beforehand.

At the bottom of the long incline leading from the Alborz Mountains, below the empty slendor of the palace of the Pahlavis and the less polluted air of upper-class north Tehran, lie the old brick factories which are south Tehran's worst slums.

Stifling in the summer, aslosh with mud in the winter, redolent of the flotsam and jetsam of the open-air sewers, the brick factories are no one's idea of pleasant living, the press is given to understand.

But the inhabitants are probably no worse off than slum dwellers in many another Third World country, judging from the number of television aerials, motorbikes and cars seen in the neighborhood.

It was in the name of the wretched of the earth that Ayatollah Ruhollah Khomeini is carrying out his Islamic revolution.

But when busloads of foreign journalists and employes from two favorite hotels debarked in their mud-house midst, they far outnumbered the locals. Officials made edifying speeches, a few locals reiterated the Iranian official line about the need to extradite ousted Shah Mohammad Reza Pahlavi to stand trial for his alleged crimes.

The sight of so many foreigners apparently surprised at least one man who had no idea that some of his visitors were Iranians.

"Those bastards have been lying to us again," one brick factory denizen said. "They told us they'd arrested all the Americans and look, they're still around."

If all foreigners are considered Americans in one man's mind, then all authority, pre- or post-revolutionary, would seem suspect, judging from the remark of another.

"They'd better look after us better," he said, referring to the revolutionary government, "or we'll make a second revolution."

Miles up the hill, at the very top of north Tehran, stands the Shah's Niavaran Palace.Its smartly uniformed Imperial Guards have gone these ten months, but there is more than a semblance of order about the place.

Revolutionary Guard, dressed in sweaters and slacks, patrol with automatic rifles. Gardeners carefully water the precisely manicured lawns. Yet a certain air of melancholy hangs about the place, perhaps the giant, blue-tiled swimming pool, perhaps the falling leaves left unattended on a crisp fall afternoon.

The first journalists to visit the palace since immediately after the February Revolution were ushered into the imperial family's living quarters.

Persian carpets worth millions of dollars lay on the marble floor ready for auction along with gold candelabras and other valuables. Samples will be kept when the place is opened to the general public as a national museum.

The pahlavis lived well. A room in the foyer could be opened under clear night skies to allow them and their guests to see the stars. A room with wall-to-wall carpet serves as a private cinema, complete with deep green armchairs and several Knoll chairs and settees. Abstract art -- including works by Pol Bury and Arlene Sherman -- decorate the walls.

In the library next door. Perhaps the last bust of shah left intact in all Iran graces a table.

Among the thousands of volumes the choice of reading is eclectic. There are rows and rows of Italian, American and French encyclopedias, Churchill's and de Gaulle's memoirs. Former Israeli Foreign Minister Abba Eban personally dedicated a book entitled "My People." "The list goes, on: Henry Miller's 'Plexus," "Nexus" and "Sexus," the Kalb brothers' biography of former secretary of state Henry Kissinger, Jerzy Kosinki's novel "Being There," Kipling, Mahatma Gandhi's selected works.

And then a book entitled "How Much is Enough," which perhaps sums up the shah's own dilemma.

Only a bit of dust, and a certain mustiness that comes from not being lived in, suggest that anything has been changed since Jan. 16 when the shah, wife and family left by air for what the sovereign promised would be only a "short vacation."

Upstairs, eight-year-old Princess Leila's six-room apartment is a joyless affair, despite telephones -- even by her bathtub -- television sets, a Snoopy quilt and walk-in closets.

In one room there's a blackboard, hi-fi set and a color photograph showing Mrs. Rosalynn Carter, daughter Amy and then Iranian ambassador to the U.S. Ardeshir Zahedi together with three of the shah's children and his mother-in-law.

In the child's bedroom, over her bed, a slightly askew photograph of the princess shows her clad in a red coat staring wistfully at the snow.

More keys are produced from an enormous ring and the shah's office in another building is thrown open.

Its two solid-gold telephones still stand on his directoire desk where he received foreign ambassadors, important visitors and occasional journalists. The mosaic of mirrors sparkle in the midday sun. The press corps studies the old flintlock rifles, arrows and shield decorating one wall. There is a gold ceremonial dragon boat dated 1670 and taken from the imperial palace in Peking, according to a plaque.

Hojjatoleslam Sayed Hassan Motafavi, resplendent in black turban and black gown, works his worry beads.

He is the revolutionary caretaker of the palace and commands some hundred Revolutionary Guards.

He seems worried about these inquisitive foreigners and says that everything belongs to Iran's 35 million people now.

There will be no latter-day equivalent of the sacking of the palace of Versailles by French revolutionary mobs, nor any pillaging like that of the Winter Palace in Petrograd in 1917.

The journalists were searched coming in and out and the doors carefully locked behind them during their visit.