President Carter yesterday claimed "almost complete agreement" with Tanzanian President Julius K. Nyerere on "goals and purposes" to resolve the black-white struggles in Rhodesia and Namibia (Southwest Africa).

Nyerere more guardedly said "I felt very encouraged" by two days of White House discussions. What counts. he said, is whether "American power" will "be put on the side of the liberation struggle in Africa."

"As a result of the talks I have had with President Carter" Nyerere said. "I feel there is a willingness in this administration to put at least some of that power behind the liberation struggle . . . Don't ask me how much. But I feel encouraged."

There was a marked difference between Carter's public emphasis on diplomacy and Nyerere's emphasis on "force" cobining guerrilla warfare and diplomatic pressure to resolve the largest conflict, in Rhodesia, where 270,000 whites rule more than 6 million blacks. What the United States can contribute most, Nyerere said, are tighter economic sanctions on Rhodesia and on South Africa, its prime ally.

Nyerere said he has "never believed" that the Rhodesian government of Prime Minister Ian D.Smith "can be argued into accepting majority rule."

"Smith has to be forced into accepting majority rule," Nyerere said, adding that the time has passed for any attempt to integrate the black nationalist guerrilla armies and Rhodesia's army. That was part of the British-American settlement plan Smith rejected last month.

"One of those armies will have to go." Nyerere said. "We believe it is the Smith army." He said " the purpose is to get rid of Smith and his power structure."

All that a settlement can do now, Nyerere said, is "shorten the war." If necessary, he said, "we can defeat Smith and his friends without assistance from the Western world," although it will take longer without Western help.

"I get arms from the Soviet Union," Nyerere said. "I get arms from China, I want to find out what kind of force I can get from here: I don't expect to get arms at all from here."

Carter told reporters after he escorted Nyerere from the Oval Office that "we hope and expect" that Nyerere will support "the basic premises of the so-called British-American plan" for a Rhodesian settlement.

The President was first to disclose that Nyerere and South African Foreign Minister R.F.(Pik) Botha, whose nation rules Namibia and controls Rhodesia's economic lifelines, will participate in talks in London this weekend on the Anglo-American plan. Secretary of State Cyrus R. Vance and British Foreign Secretary David Owen originally planned the meeting to coordinate their policy.

Carter said there have been "encouraging, constructive moves in South Africa" on granting independence and majority rule to Namibia. This sets the scene, he said, for talks in New York in the next few days with Sam Nujoma, head of the Southwest Africa People's Organization, and a possible agreement with the "front-line" sates - Tanzania, Mozambique, Zambia, Angola, Botswana - in the Rhodesian and Namibian conflicts.

If South Africa continues to show "a cooperative attitude" in working with the United Nations to bring about "a free Namibia," Carter said, "I think the threat of additional sanctions (against South Africa) would be inappropriate now."

Although Nyerere pressed for more sanctions, he commended Carter's overall attitude toward Africa's liberation struggle. Nyerere said, "I find the present administration doesn't believe that those who are forced to take up arms ti fight for the independence of their countries are necessarily Communists."

In Rohodesia, the core of a solution, Nyerere said, is "getting rid os Smith," producing a constitution and holding "elections on the basis of one-man, one-vote."

When a reporter asked if Nyerere believed the previous British-American plan failed to "put the screws on" Smith, Nyerere laughingly said: "I have a feeling that they did not screw him enough."

In discussing his country, Nyerere acknowledged that there are "political detainees" in Tanzania. "depending on your definition." But he said it is "a silly idea" to claim, as was recently reported, that there are 3,000 political prisoners in Tanzania, a one-party state.

Nyerere said there are "a few...politicians or individuals who are locked up somewhere who are opposed to the system." At one point he mentioned "four on the mainland" and he also said "we have about 17." Nyerere said some "detainees" are being held for SWAPO. the Namibian nationalist group, and some for the Rhodesian nationalist group. ZANU (Zimbabwe African Nationalist Union).