SharedDIMA.ipynbOpen in CoCalc
#num1
import random
from math import ceil

rm = [random.randint(-5, 5) for x in range(8)]
print(rm)
def halfchange(arr, size):
return list(map(lambda x: arr[x * size:x * size + size],
list(range(0, ceil(len(arr) / size)))))
print(halfchange(rm, int(len(rm)/2)))
a, b = halfchange(rm, int(len(rm)/2))[0], halfchange(rm, int(len(rm)/2))[1]
a, b = b, a
print([a, b])

[-4, -4, 4, 2, 1, 1, -3, -1] [[-4, -4, 4, 2], [1, 1, -3, -1]] [[1, 1, -3, -1], [-4, -4, 4, 2]]
#num2
import string
print(chr(128522))

😊
index = 0
matriza_vvoda = []
while index == 0:
matriza_vvoda += [input().split(' ')]
last = matriza_vvoda.pop()
if last == ['end']:
index = 1
else:
matriza_vvoda += [last]
mt = []
mt += [matriza_vvoda[i][0] for i in range(len(matriza_vvoda))]
m = [' '.join(matriza_vvoda[i]) for i in range(len(matriza_vvoda))]

res = []
for i in range(len(m)):
a = len([c for c in m[i] if c in 'aeiouAEIOU'])
res += ['Гласных = {0}'.format(a)]

res

['Гласных = 5', 'Гласных = 7']
#num3
import random
import numpy as np
import numpy.linalg as li
N = 4; M = 5

A = np.array([[random.randint(-10, 10) for x in range(N)] for j in range(M)])
a = abs(A)
sm = [sum(x) for x in a]

mx = sm[0]
for i in range(len(sm)):
if sm[i] > mx:
mx = sm[i]
imx = i

print(A, '\n', 'min=', min(A[imx]),'\n', sm)

[[-10 7 -7 2] [ -2 3 8 7] [ 8 -8 9 3] [ -5 -5 -4 -8] [ 10 -6 -5 -5]] min= -8 [26, 20, 28, 22, 26]
#num4
import numpy as np

A = np.reshape([np.random.randint(3,5) for x in range(60)],(4,15));A = np.array(A);A

array([[4, 4, 3, 4, 4, 4, 4, 4, 3, 4, 3, 4, 4, 3, 3], [4, 4, 4, 3, 4, 4, 3, 4, 4, 3, 3, 3, 4, 3, 3], [4, 4, 4, 4, 4, 3, 4, 4, 3, 3, 4, 3, 3, 3, 4], [4, 3, 3, 4, 4, 4, 4, 3, 4, 4, 4, 4, 3, 3, 4]])
AA = np.vstack(((np.array([x for x in range(len(A[0]))])).transpose(), A));print(AA)
a = AA.transpose();print(a)

[[ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14] [ 4 4 3 4 4 4 4 4 3 4 3 4 4 3 3] [ 4 4 4 3 4 4 3 4 4 3 3 3 4 3 3] [ 4 4 4 4 4 3 4 4 3 3 4 3 3 3 4] [ 4 3 3 4 4 4 4 3 4 4 4 4 3 3 4]] [[ 0 4 4 4 4] [ 1 4 4 4 3] [ 2 3 4 4 3] [ 3 4 3 4 4] [ 4 4 4 4 4] [ 5 4 4 3 4] [ 6 4 3 4 4] [ 7 4 4 4 3] [ 8 3 4 3 4] [ 9 4 3 3 4] [10 3 3 4 4] [11 4 3 3 4] [12 4 4 3 3] [13 3 3 3 3] [14 3 3 4 4]]
thr = [x for x in a if int(sum(x[1:] == 3)/len(x[1:]) == 1) ];
print([x[0] for x in thr],'\n', len(thr))

[13] 1
print([int(sum(x[1:] == 3)/len(x[1:])) for x in a ])

[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0]