Skip to main content
added 3 characters in body
Source Link

Python 3.13 random CLI

Starting with Python 3.13 all of the following will generate a random integer between 1 and N10 inclusive:

python -m random N10
python -m random -i N10
python -m random --integer N10

Previously you would also do it with -c as mentioned at https://unix.stackexchange.com/a/140767/32558 but now it is cuter.

It doesn't seem to be possible to change the lower bound (1) with this method just yet.

Documented at: https://docs.python.org/3/library/random.html#random-cli

Tested on Python 3.13.3, Ubuntu 25.04.

Python 3.13 random CLI

Starting with Python 3.13 all the following will generate a random integer between 1 and N inclusive:

python -m random N
python -m random -i N
python -m random --integer N

Previously you would also do it with -c as mentioned at https://unix.stackexchange.com/a/140767/32558 but now it is cuter.

It doesn't seem to be possible to change the lower bound (1) with this method just yet.

Documented at: https://docs.python.org/3/library/random.html#random-cli

Python 3.13 random CLI

Starting with Python 3.13 all of the following will generate a random integer between 1 and 10 inclusive:

python -m random 10
python -m random -i 10
python -m random --integer 10

Previously you would also do it with -c as mentioned at https://unix.stackexchange.com/a/140767/32558 but now it is cuter.

It doesn't seem to be possible to change the lower bound (1) with this method just yet.

Documented at: https://docs.python.org/3/library/random.html#random-cli

Tested on Python 3.13.3, Ubuntu 25.04.

added 75 characters in body
Source Link

Python 3.13 random CLI

Starting with Python 3.13 all the following will generate a random integer between 1 and N inclusive:

python -m random N
python -m random -i N
python -m random --integer N

Previously you would also do it with -c as mentioned at https://unix.stackexchange.com/a/140767/32558 but now it is cuter.

It doesn't seem to be possible to change the lower bound (1) with this method just yet.

Documented at: https://docs.python.org/3/library/random.html#random-cli

Python 3.13 random CLI

Starting with Python 3.13 all the following will generate a random integer between 1 and N inclusive:

python -m random N
python -m random -i N
python -m random --integer N

Previously you would also do it with -c as mentioned at https://unix.stackexchange.com/a/140767/32558 but now it is cuter.

It doesn't seem to be possible to change the lower bound (1) with this method just yet.

Python 3.13 random CLI

Starting with Python 3.13 all the following will generate a random integer between 1 and N inclusive:

python -m random N
python -m random -i N
python -m random --integer N

Previously you would also do it with -c as mentioned at https://unix.stackexchange.com/a/140767/32558 but now it is cuter.

It doesn't seem to be possible to change the lower bound (1) with this method just yet.

Documented at: https://docs.python.org/3/library/random.html#random-cli

Source Link

Python 3.13 random CLI

Starting with Python 3.13 all the following will generate a random integer between 1 and N inclusive:

python -m random N
python -m random -i N
python -m random --integer N

Previously you would also do it with -c as mentioned at https://unix.stackexchange.com/a/140767/32558 but now it is cuter.

It doesn't seem to be possible to change the lower bound (1) with this method just yet.