mercredi 28 octobre 2020

I want to make a numpy array

As the title says I want to make a numpy array.

array=np.random.randint(2,size=(4,4))

First question, at this time I want to make code that size can be changeable. What should I do?

top = input("Top(k):")

Second question, I want to receive k value like this and send output as much as this value. At this time, I wanna print the top k-row indexes from the weakest to the strongest (weakest:smaller number of ones) How to do it??:(

example like this.

input

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

Top(k):2

output

0,2

if Top(k):4, output is

0,2,3,1




Aucun commentaire:

Enregistrer un commentaire