Перевести на Python
type
TArray = Array[0..19] Of Real;
procedure RandomArray(var ar: TArray; const mes: String);
var
k: Byte;
begin
Write(mes, ':');
for k := 0 to 19 do
begin
ar[k] := Random() * 198 - 99;
Write(ar[k]:7:2);
end;
WriteLn;
end;
function SumXY(const x, y: TArray): Double;
var
k: Byte;
S: Double;
begin
S := 0;
for k := 1 to 15 do
S := S + x[k] * y[k];
SumXY := S;
end;
function P(const z: TArray): Double;
var
k: Byte;
S: Double;
begin
S := 0;
for k := 0 to 19 do
S := S + Sqr(z[k]);
P := S;
end;
var
x, y: TArray;
begin
Randomize();
RandomArray(x, 'X'); RandomArray(y, 'Y');
if (SumXY(x, y) > 0)
then
Write('P(x)=', P(x):0:3)
else
Write('P(y)=', P(y):0:3);
end.