-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscripts.py
More file actions
1192 lines (819 loc) · 25.3 KB
/
scripts.py
File metadata and controls
1192 lines (819 loc) · 25.3 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#Introduction
#0 Solve Me First
def solveMeFirst(a,b):
# Hint: Type return a+b below
return a+b
num1 = int(input())
num2 = int(input())
res = solveMeFirst(num1,num2)
print(res)
#-----------------------------------------
#1 Say "Hello, World!" With Python
print("Hello, World!")
#---------------------------------------------------
#2 Python If-Else
import math
import os
import random
import re
import sys
if __name__ == '__main__':
n = int(input().strip())
if n%2!=0 or n==0 :
print("Weird")
else:
if 2<=n<=5:
print("Not Weird")
elif 6<=n<=20:
print('Weird')
else:
print('Not Weird')
#--------------------------------------
#3 Arithmetic Operators
if __name__ == '__main__':
a = int(input())
b = int(input())
print(a+b)
print(a-b)
print(a*b)
#-------------------------------------------
#4 Python: Division
if __name__ == '__main__':
a = int(input())
b = int(input())
print(a//b)
print(a/b)
#-----------------------------------------
#5 Loops
if __name__ == '__main__':
n = int(input())
for i in range(n):
print(i**2)
#----------------------------------------------
#6 Write a function
def is_leap(year):
leap = False
if year%4==0:
leap=True
if year%100==0:
leap = False
if year%400==0:
leap=True
return leap
#-----------------------------------------------
#7 Print Function
if __name__ == '__main__':
n = int(input())
l=str('')
for i in range(n):
l=l+str(i+1)
print(l)
####################################################
####################################################
# DATA TYPES CHALLENGE
#1 List Comprehensions
if __name__ == '__main__':
x = int(input())
y = int(input())
z = int(input())
n = int(input())
m=[]
c=0
for i in range(x+1):
for j in range(y+1):
for k in range(z+1):
if (i+k+j!=n):
m.append([])
m[c]=[i,j,k]
c=c+1
print(m)
#---------------------------------------------------
#2 Find the Runner-Up Score!
if __name__ == '__main__':
n = int(input())
arr = map(int, input().split())
arr=sorted(arr)
ok=int()
for i in range(len(arr)-1,-1,-1):
if (arr[-1]>arr[i]):
ok=arr[i]
break
print(ok)
#------------------------------------------------------
#3 Nested Lists
#i looked part of solutions
sc=[]
nm=[]
if __name__ == '__main__':
for _ in range(int(input())):
name = input()
score = float(input())
sc.append(score)
nm.append(name)
scoreord=sorted(sc)
low=0
for i in range(0, len(scoreord)):
if(scoreord[i]>scoreord[0]):
low=scoreord[i]
break
namelow=[]
for i in range(0,len(sc)):
if(sc[i]==low):
namelow.append(nm[i])
namelow2=sorted(namelow)
for i in range(0, len(namelow2)):
print(namelow2[i])
#-----------------------------------------------------
#4 Finding the percentage
if __name__ == '__main__':
n = int(input())
student_marks = {}
for _ in range(n):
name, *line = input().split()
scores = list(map(float, line))
student_marks[name] = scores
query_name = input()
add=0
for i in (student_marks[query_name]):
add+=i
print('%.2f' %(add/3))
#--------------------------------------------------------
#5 Lists
#Looking solutions, the request is hard to understand
if __name__ == '__main__':
N = int(input())
listt = []
while N > 0:
q = list(map(str,input().split()))
if q[0] == "print":
print(listt)
elif q[0] == "insert":
listt.insert(int(q[1]),int(q[2]))
elif q[0] == "remove":
listt.remove(int(q[1]))
elif q[0] == "append":
listt.append(int(q[1]))
elif q[0] == "sort":
listt.sort()
elif q[0] == "pop":
listt.pop()
elif q[0] == "reverse":
listt.reverse()
N -= 1
#-----------------------------------------------------------
#6 Tuples
if __name__ == '__main__':
n = int(input())
integer_list = map(int, input().split())
print(hash(tuple(integer_list)))
##############################################################
#################################################################
# STRINGS CHALLENGE
#1 sWAP cASE
def swap_case(s):
s=s.swapcase()
return s
#---------------------------------------------------------------
#2 String Split and Join
def split_and_join(line):
line=line.split(" ")
line="-".join(line)
return line
#---------------------------------------------------------------
#3 What's Your Name?
def print_full_name(a, b):
print("Hello",a, str(b)+"! You just delved into python.")
#--------------------------------------------------------------
#4 Mutations
def mutate_string(string, position, character):
string=string[:position]+character+string[position+1:]
return string
#-------------------------------------------------------------
#5 Find a string
def count_substring(string, sub_string):
c=0
for i in range(len(string)-len(sub_string)+ 1):
if string[i:i+len(sub_string)]==sub_string:
c+=1
return c
#----------------------------------------------------------------
#6 String Validators
#I LOOKED AT THE SOLUTION FOR AN ALTERNATIVE WAY OF WRITING THE CYCLE
if __name__ == '__main__':
s = input()
print(any([char.isalnum() for char in s]))
print(any([char.isalpha() for char in s]))
print(any([char.isdigit() for char in s]))
print(any([char.islower() for char in s]))
print(any([char.isupper() for char in s]))
#---------------------------------------------------------------
#7 Text Alignment
thickness = int(input()) #This must be an odd number
c = 'H'
#Top Cone
for i in range(thickness):
print((c*i).rjust(thickness-1)+c+(c*i).ljust(thickness-1))
# Top Pillars
for i in range(thickness+1):
print((c*thickness).center(thickness*2)+(c*thickness).center(thickness*6))
# Middle Belt
for i in range((thickness+1)//2):
print((c*thickness*5).center(thickness*6))
# Bottom Pillars
for i in range(thickness+1):
print((c*thickness).center(thickness*2)+(c*thickness).center(thickness*6))
# Bottom Cone
for i in range(thickness):
print(((c*(thickness-i-1)).rjust(thickness)+c+(c*(thickness-i-1)).ljust(thickness)).rjust(thickness*6))
#--------------------------------------------------------
#8 Text Wrap
def wrap(string, max_width):
wrap=textwrap.fill(string, max_width)
return wrap
#--------------------------------------------------------
#9 Designer Door Mat
#Looking solution
alt, lun = map(int, input().split())
for i in range(0, alt//2):
s = '.|.'*(i*2 + 1)
print(s.center(lun,'-'))
print('WELCOME'.center(lun, '-'))
for i in range(alt//2-1,-1,-1):
s = '.|.'*(i*2+1)
print(s.center(lun,'-'))
#-----------------------------------------------------------------
#10 String Formatting
def print_formatted(number):
form = len("{0:b}".format(number))
for i in range(1, number + 1):
print("{0:{form}d} {0:{form}o} {0:{form}X} {0:{form}b}".format(i, form=form))
#------------------------------------------------------------------
#11 Capitalize!
#I looked part of solution to see how to enter the spaces
def solve(s):
s=' '.join(s.capitalize() for s in s.split(' '))
return s
#------------------------------------------------------------------
#12 Alphabet Rangoli
#I looked Solution
import string
def print_rangoli(size):
a = string.ascii_lowercase
r = []
for i in range(size):
s = "-".join(a[i:size])
r.append((s[::-1]+s[1:]).center(4*size-3, "-"))
print('\n'.join(r[:0:-1]+r))
#-------------------------------------------------------------------
#13 The Minion Game
def minion_game(string):
length = len(string)
the_vowel = "AEIOU"
kiven = 0
stuart = 0
for i in range(length):
if string[i] in the_vowel:
kiven = kiven + length - i
else:
stuart = stuart + length - i
if (kiven > stuart):
print ("Kevin", kiven)
elif (kiven < stuart):
print ("Stuart", stuart)
else:
print ("Draw")
#-------------------------------------------------------------
#14 Merge the Tools!
def merge_the_tools(string, k):
num = int(len(string) / k)
for i in range(num):
x = string[i*k : (i+1)*k]
eq = ""
for j in x:
if (j not in eq):
eq+=j
print(eq)
#----------------------------------------------------------------
#################################################################
###############################################################
# SETS CHALLENGE
#1 Introduction to Sets
def average(array):
a= set(array)
m=sum(a)/len(a)
return m
#-----------------------------------------------------------------
#2 No Idea!
(n,m) = map(int, input().split())
arr = map(int, input().split())
A = set(map(int, input().split()))
B = set(map(int, input().split()))
happ=0
for i in arr:
if i in A:
happ+=1
elif i in B:
happ-=1
print (happ)
#-------------------------------------------------------------------
#now I use the numbering found on slack, sorry
# Exercise 30 - Sets - Symmetric Difference
#Solution. I don't understand request...
A,B= [set(input().split()) for _ in range(4)][1::2]
print('\n'.join(sorted(A.symmetric_difference(B), key=int)))
# Exercise 31 - Sets - Set .add()
N=int(input())
country=set()
for _ in range(1,N):
country.add(input())
print(len(country))
# Exercise 32 - Sets - Set .discard(), .remove() & .pop()
n = int(input())
s = set(map(int, input().split()))
for i in range(int(input())):
eval('s.{0}({1})'.format(*input().split()+['']))
print(sum(s))
# Exercise 33 - Sets - Set .union() Operation
a=input()
A=set(map(int,input().split()))
b=input()
B=set(map(int,input().split()))
print (len(A.union(B)))
# Exercise 34 - Sets - Set .intersection() Operation
a=input()
A=set(map(int,input().split()))
b=input()
B=set(map(int,input().split()))
print (len(A.intersection(B)))
# Exercise 35 - Sets - Set .difference() Operation
a=input()
A=set(map(int,input().split()))
b=input()
B=set(map(int,input().split()))
print (len(A.difference(B)))
# Exercise 36 - Sets - Set .symmetric_difference() Operation
a=input()
A=set(map(int,input().split()))
b=input()
B=set(map(int,input().split()))
print (len(A.symmetric_difference(B)))
# Exercise 37 - Sets - Set Mutations
length=int(input())
ins=set(map(int, input().split()))
N=int(input())
for i in range(N):
(p, q)=input().split()
ins2=set(map(int,input().split()))
if p=='intersection_update':
ins.intersection_update(ins2)
elif p=='update':
ins.update(ins2)
elif p=='symmetric_difference_update':
ins.symmetric_difference_update(ins2)
elif p=='difference_update':
ins.difference_update(ins2)
print (sum(ins))
# Exercise 38 - Sets - The Captain's Room
K=input()
set1=set()
set2=set()
for i in (input().split()):
if i not in set1:
set1.add(i)
else:
set2.add(i)
set1.difference_update(set2)
print(set1.pop())
# Exercise 39 - Sets - Check Subset
for _ in range(int(input())):
a=input()
A=set(input().split())
b=input()
B=set(input().split())
print(A.issubset(B))
# Exercise 40 - Sets - Check Strict Superset
supers=set(input().split())
B = set()
for _ in range(int(input())):
B |= set(input().split()) #i've look on internet for |=
print (not bool(B ^ supers))
# Exercise 41 - Collections - collections.Counter()
from collections import Counter
shoes=int(input())
sizes=Counter(map(int, input().split()))
cust=int(input())
sale=0
for _ in range(cust):
s,p=map(int,input().split())
if sizes[s]:
sale+=p
sizes[s]=sizes[s]-1
print(sale)
# Exercise 42 - Collections - DefaultDict Tutorial
from collections import defaultdict
n,m=map(int,input().split())
d=defaultdict(list)
for i in range(0,n):
d[input()].append(i+1)
b=[]
for j in range(0,m):
b=b+[input()]
for i in b:
if(i in d):
print(" ".join(map(str,d[i])))
else:
print(-1)
# Exercise 43 - Collections - Collections.namedtuple()
#looking solution to understand 'namedtuple'
from collections import namedtuple
n=int(input())
col=input().split()
markstot=0
for _ in range(n):
students = namedtuple('student', col)
MARKS, CLASS, NAME, ID = input().split()
student = students(MARKS, CLASS, NAME, ID)
markstot += int(student.MARKS)
print('{:.2f}'.format(markstot / n))
# Exercise 44 - Collections - Collections.OrderedDict()
from collections import OrderedDict
dic=OrderedDict()
n=int(input())
for _ in range(n):
item=input().split()
iprice=int(item[-1])
iname=" ".join(item[:-1])
if dic.get(iname):
dic[iname]+=iprice
else:
dic[iname]=iprice
for j in dic.keys():
print(j, dic[j])
# Exercise 45 - Collections - Word Order
from collections import *
n=int(input())
dic=OrderedDict()
for _ in range(n):
read=input()
if read in dic:
dic[read]+=1
else:
dic[read]=1
print(len(dic))
print (' '.join(map(str, dic.values())))
# Exercise 46 - Collections - Collections.deque()
from collections import deque
f=deque()
for _ in range(int(input())):
com = input().strip().split()
if (com[0] == 'append'):
f.append(com[1])
elif (com[0] == 'pop'):
f.pop()
elif (com[0] == 'popleft'):
f.popleft()
elif (com[0] == 'appendleft'):
f.appendleft(com[1])
print (' '.join(f))
# Exercise 47 - Collections - Company Logo
import math
import os
import random
import re
import sys
import collections
if __name__ == '__main__':
s = input().strip()
s=sorted(s)
scont=collections.Counter(s).most_common()
scont=sorted(scont, key=lambda x: (x[1] * -1, x[0])) #solution for key=lambda.....
for i in range(0, 3):
print(scont[i][0], scont[i][1])
# Exercise 48 - Collections - Piling Up!
#NO
# Exercise 49 - Date time - Calendar Module
import calendar
mese,gg,anno=map(int,input().strip().split())
dayweek=calendar.day_name[calendar.weekday(anno,mese,gg)].upper()
print(dayweek)
# Exercise 50 - Date time - Time Delta
import math
import os
import random
import re
import sys
from datetime import datetime
# Complete the time_delta function below.
def time_delta(t1, t2):
uno = datetime.strptime(t1, "%a %d %b %Y %X %z")
due = datetime.strptime(t2, "%a %d %b %Y %X %z")
return str(int(abs((uno-due).total_seconds())))
if __name__ == '__main__':
fptr = open(os.environ['OUTPUT_PATH'], 'w')
t = int(input())
for t_itr in range(t):
t1 = input()
t2 = input()
delta = time_delta(t1, t2)
fptr.write(delta + '\n')
fptr.close()
# Exercise 51 - Exceptions -
n=int(input())
for _ in range(n):
a,b=input().split()
try:
print(int(a)//int(b))
except Exception as e:
print ("Error Code: " + str(e)) #solution for str()
# Exercise 52 - Built-ins - Zipped!
n,x=map(int,input().split())
sub=list()
for i in range(x):
sub.append(map(float, input().split())) #matrix
stud=zip(*sub)
for i in stud:
print(sum(i)/x)
# Exercise 53 - Built-ins - Athlete Sort
if __name__ == '__main__':
nm = input().split()
n = int(nm[0])
m = int(nm[1])
arr = []
for _ in range(n):
arr.append(list(map(int, input().rstrip().split())))
k = int(input())
arr = sorted(arr, key=lambda col: col[k])
for i in range(n):
print(" ".join(str(x) for x in arr[i]))
# Exercise 54 - Built-ins - Ginorts
#I looked solution, I had no idea how to do it fast but i was sure there was a
#good way better than mine.
print(*sorted(input(), key=lambda c: (-ord(c) >> 5, c in '02468', c)), sep='')
# Exercise 55 - Map and lambda function
cube = lambda x: x ** 3 # complete the lambda function
def fibonacci(n):
# return a list of fibonacci numbers
seq= [0, 1]
for i in range(2, n):
seq.append(seq[i-1] + seq[i-2])
return(seq[0:n]) #i addedd [0:n] after looking at the solution
cube = lambda x: x ** 3
if __name__ == '__main__':
n = int(input())
print(list(map(cube, fibonacci(n))))
#I NEVER STUDIED REGEX, XML AND DECORATORS... I'LL STUDY AND I'LL
#COMPLETE THEM IN NEXT WEEKS
# Exercise 56 - Regex - Detect Floating Point Number
# Exercise 57 - Regex - Re.split()
# Exercise 58 - Regex - Group(), Groups() & Groupdict()
# Exercise 59 - Regex - Re.findall() & Re.finditer()
# Exercise 60 - Regex - Re.start() & Re.end()
# Exercise 61 - Regex - Regex Substitution
# Exercise 62 - Regex - Validating Roman Numerals
# Exercise 63 - Regex - Validating phone numbers
# Exercise 64 - Regex - Validating and Parsing Email Addresses
# Exercise 65 - Regex - Hex Color Code
# Exercise 66 - Regex - HTML Parser - Part 1
# Exercise 67 - Regex - HTML Parser - Part 2
# Exercise 68 - Regex - Detect HTML Tags, Attributes and Attribute Values
# Exercise 69 - Regex - Validating UID
# Exercise 70 - Regex - Validating Credit Card Numbers
# Exercise 71 - Regex - Validating Postal Codes
# Exercise 72 - Regex - Matrix Script
# Exercise 73 - Xml - XML 1 - Find the Score
# Exercise 74 - Xml - XML 2 - Find the Maximum Depth
# Exercise 75 - Closures and decorators - Standardize Mobile Number Using Decorators
# Exercise 76 - Closures and decorators - Decorators 2 - Name Directory
# Exercise 77 - Numpy - Arrays
def arrays(arr):
a=list(reversed(arr))
a1=numpy.array(a,float)
return a1
# Exercise 78 - Numpy - Shape and Reshape
import numpy
arr=input().split()
arr = numpy.array(arr, int)
print (numpy.reshape(arr,(3,3)))
# Exercise 79 - Numpy - Transpose and Flatten
import numpy
n,m=map(int,input().split())
arr = list()
for i in range(n):
arr.append(input().split())
matrice=numpy.reshape(numpy.array(arr, int), (n,m))
print(matrice.transpose())
print(matrice.flatten())
# Exercise 80 - Numpy - Concatenate
import numpy
n,m,p=map(int,input().split())
narr=[list(map(int, input().split())) for i in range(n)]
marr=[list(map(int, input().split())) for i in range(m)]
arr1=(numpy.array(narr))
arr2=(numpy.array(marr))
print(numpy.concatenate((arr1,arr2),axis=0))
# Exercise 81 - Numpy - Zeros and Ones
import numpy
mat=tuple(map(int,input().strip().split()))
print(numpy.zeros(mat, dtype = numpy.int))
print(numpy.ones(mat, dtype=numpy.int))
# Exercise 82 - Numpy - Eye and Identity
import numpy
r,c=map(int,input().split())
numpy.set_printoptions(sign=' ') #looking solution for the space, the output was rigth!
print(numpy.eye(r,c))
# Exercise 83 - Numpy - Array Mathematics
import numpy
n,m=map(int,input().split())
arr1= numpy.array([list(map(int,input().split())) for i in range(n)])
arr2= numpy.array([list(map(int,input().split())) for i in range(n)])
print (numpy.add(arr1,arr2))
print (numpy.subtract(arr1,arr2) )
print (numpy.multiply(arr1,arr2) )
print (arr1//arr2 )
print (numpy.mod(arr1,arr2) )
print (numpy.power(arr1,arr2))
# Exercise 84 - Numpy - Floor, Ceil and Rint
import numpy
a=numpy.array(list(map(float,input().split())))
numpy.set_printoptions(sign=' ')
print(numpy.floor(a))
print(numpy.ceil(a))
print(numpy.rint(a))
# Exercise 85 - Numpy - Sum and Prod
import numpy
n,m=map(int,input().split())
a=numpy.array([input().split() for _ in range(n)],int)
print(numpy.prod(numpy.sum(a, axis = 0),axis=0))
# Exercise 86 - Numpy - Min and Max
import numpy
n,m = map(int, input().split())
a = numpy.array([input().split() for _ in range(n)],int)
print(numpy.max(numpy.min(a, axis=1), axis=0)) #solution, i had a problem with axis=1
# Exercise 87 - Numpy - Mean, Var, and Std
import numpy
n,m=map(int,input().split())
a = numpy.array([input().split() for _ in range(n)],int)
numpy.set_printoptions(sign=' ')
print(numpy.mean(a, axis=1))
print(numpy.var(a,axis=0))
print(numpy.around(numpy.std(a),12))
# Exercise 88 - Numpy - Dot and Cross
import numpy
n=int(input())
a= numpy.array([input().split() for _ in range(n)],int)
b= numpy.array([input().split() for _ in range(n)],int)
print(numpy.dot(a,b))
# Exercise 89 - Numpy - Inner and Outer
import numpy
a= numpy.array(list(map(int,input().split())))
b= numpy.array(list(map(int,input().split())))
print(numpy.inner(a,b))
print(numpy.outer(a,b))
# Exercise 90 - Numpy - Polynomials
import numpy
a = numpy.array(list(map(float, input().split())))
pos=float(input())
print( numpy.polyval(a, pos))
# Exercise 91 - Numpy - Linear Algebra
import numpy
n=int(input())
mat= numpy.array( [input().split() for _ in range(n)],float)
numpy.set_printoptions(legacy='1.13') #solution for this line
print(round(numpy.linalg.det(mat),2))
# ===== PROBLEM2 =====
# Exercise 92 - Challenges - Birthday Cake Candles
import math
import os
import random
import re
import sys