import random A = [random.randint(-10, 22) for i in range(20)] cnt = num = 0 for i in A: if i >5: cnt += i num += 1 print "Среднее арифметическое - ", float(cnt)/float(num)
Program darixa; var a:array[1..20] of integer; i,sum,index:integer; begin for i:=1 to 20 do begin a[i]:=random(32)-10; if a[i]>5 then begin sum:=sum+a[i]; index:=index+1; end; write(a[i],' '); end; writeln('Sredn=',sum/index); end.
import random
A = [random.randint(-10, 22) for i in range(20)]
cnt = num = 0
for i in A:
if i >5:
cnt += i
num += 1
print "Среднее арифметическое - ", float(cnt)/float(num)
var a:array[1..20] of integer;
i,sum,index:integer;
begin
for i:=1 to 20 do begin
a[i]:=random(32)-10;
if a[i]>5 then begin
sum:=sum+a[i];
index:=index+1;
end;
write(a[i],' ');
end;
writeln('Sredn=',sum/index);
end.