I will take a coding test, so make a note of it. I will make a note so I will update it. Please forgive me because it is a texto
2019/12/15 For the time being, I will do it with python that I usually use. Should I move to C ++ if I'm a competition pro?
2019/12/16 I want to solve the past questions of AtCoder For the time being, I made a repository on github. βshort repository
This is a memo related to grammar and numpy.
Reference: https://qiita.com/fmhr/items/77fc453e2fb1bc02e392
a, b, c, d = map(int, input().split())
#Input 1 3 4 5
a = [int(i) for i in input().split()]
#a=[1 3 4 5]
a = [i for i in input().split()]
In case of multiple, specify by index For 2-digit decimal
#{Index number:Format specification}.format()
print("{0:02d}".format(1))
#01
print("Characters etc.", end='')
#Round up
math.ceil()
#Truncate
math.floor()
#Rounding
round()
Binary: bin () Eighth number: oct () Hexadecimal: hex ()
All match'abc'=='abcd' is False Negation is! =
Partial match'abc' in'abcd' is True Negation is not in
s.count('a')
s.replace("Before replacement", "After replacement")
#String=>list
s = list("String")
s[2] = "formula"
s = "".join(s)
list https://docs.python.org/ja/3/tutorial/datastructures.html To count the number of each element (the number of occurrences for each element), use the count () method.
a.append("Value you want to store")
a.remove("Value you want to delete")
a.pop()
List comprehension
[i for i in range(10)]
#ascending order
a.sort()
#descending order
a.sort(reverse=True)
sum(a)
map is an apply function in pandas
map(func, list)
set
a.add()
a.delete()
dict
numpy
np.zeros('shape')
np.ones('shape')
np.full('shape', 'value')
np.count_nonzero(a < 4)
#https://qiita.com/shippokun/items/01c85e36b8de7afd01a6
maxValue = np.max(a)
maxIndex = []
for i in range(len(a)):
if maxVaule == a[i]:
maxIndex.append(i)
print(maxIndex) # [1, 4]
np.where(conditions, True, False))
Recommended Posts