0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

指定の範囲で、指定の個数のランダムな数字をPython One Linerで生成する

Posted at

What's?

タイトルどおりということで、メモ。

環境

$ python3 -V
Python 3.10.6

やり方

randomforの組み合わせで。

$ python3 -c 'from random import randint; [ print (randint([最小], [最大])) for num in range([個数])]'

例、10から30までの範囲で、20個の数字を出力。

$ python3 -c 'from random import randint; [ print (randint(10, 30)) for num in range(20)]'
14
30
10
24
16
30
10
24
15
18
29
22
19
12
27
27
28
16
26
20

ユニーク性は考えてません。

0
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?