-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtask3.py
54 lines (47 loc) · 999 Bytes
/
task3.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import numpy as np
import random
import math
def print_arr(a):
global n
for i in range(n):
for j in range(n):
print(a[i][j],end=' ')
print()
def middle(a):
global n
s=0
for i in range(n):
for j in range(n):
s+=a[i][j]
return(s/n**2)
def dis(a):
global n
global S
D = 0
for i in range(n):
for j in range(n):
D+=(a[i][j]-S)**2
return(math.sqrt(D/(n*n-1)))
def obr(a):
global n
global S
global D
for i in range(n):
for j in range(n):
if (math.fabs(a[i][j])>D):
a[i][j]=S
a = []
print('Ведите размер:')
n = int(input())
for i in range(n):
a.append([])
for j in range(n):
a[i].append(random.randint(-100,100))
print_arr(a)
S = middle(a)
D = dis(a)
print('Среднее ',S)
print('Среднее квадратическое отклонение ',D)
print('Новый массив')
obr(a)
print_arr(a)