-
Notifications
You must be signed in to change notification settings - Fork 0
/
matix.py
53 lines (48 loc) · 1.04 KB
/
matix.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
#transpose of a matrix
lst=[[1,2],[3,4],[5,6]]
result=[[lst[j][i] for j in range(len(lst))] for i in range(len(lst[0]))]
#adding matrices
a1=[[1,2,3],
[1,2,3],
[3,4,5]]
a2=[[8,3,4],
[2,3,4],
[1,6,5]]
result=[[a1[i][j]+a2[i][j] for j in range(len(a1[0]))] for i in range(len(a1))]
#mutiplication matrices
a3=[[1,2,3],
[4,5,6]]
a4=[[7,8],
[9,10],
[11,12]]
result=[[0,0],
[0,0]]
for i in range(len(a3)):
for j in range(len(a4[0])):
for k in range(len(a4)):
result[i][j]+=a3[i][k]*a4[k][j]
result=[[sum(a*b for a,b in zip(x,y)) for y in zip(*a4)] for x in a3]
for x in a3:
for y in zip(*a4):
for a,b in zip(x,y):
print(a,b)
v='aeiou'
s='aheybjk uhiausgd Lahudhao'
dc={}
for i in s:
if i in v:
if i in dc:
dc[i]+=1
else:
dc[i]=1
n=2345
rn=0
while n>0:
remainder=n%10
rn=rn*10+remainder
n=n//10
import numpy as np
array = np.random.rand(2, 2, 2, 2)
print(array)
print(array[..., 0])
print(array[Ellipsis, 0])