Huawei machine test questions

Huawei machine test questions

Topics requirements:
Obviously want to invite some students in the school together to do a survey, in order to test the objectivity, his first with the computer-generated random integer (N <= 1000) between 1 ~ 1000 N number, N is entered by the user, wherein for duplicate numbers, but one, to remove the remaining the same numerals, corresponding to the number of different students learn different number, then put these numbers from small to large order, according to the investigation to find someone to do good order row, Please help obviously complete "de-duplication" with the sort of work.

We use python to do:

import random
s = set([])

for i in range(int(input('N:'))):
    s.add(random.randint(1,1000))
print(sorted(s))

Output:
Here Insert Picture Description

Published 60 original articles · won praise 6 · views 1373

Guess you like

Origin blog.csdn.net/weixin_45775963/article/details/103633366