I want to make a random number between 1 and 30 I read the document but i can't find a method for do it
for example we do it in php by
rand(1 , 30);
How can i handle it
I want to make a random number between 1 and 30 I read the document but i can't find a method for do it
for example we do it in php by
rand(1 , 30);
How can i handle it
It's explained in the docs https://docs.julialang.org/en/v1/stdlib/Random/#Base.rand
rand([rng=GLOBAL_RNG], [S], [dims...])
Pick a random element or array of random elements from the set of values specified by S; S can be
- an indexable collection (for example 1:9 or ('x', "y", :z)),
- an AbstractDict or AbstractSet object,
- a string (considered as a collection of characters), or
- a type: the set of values to pick from is then equivalent to typemin(S):typemax(S) for integers (this is not applicable to BigInt), to [0,1)[0, 1)[0,1) for floating point numbers and to [0,1)+i[0,1)[0, 1)+i[0, 1)[0,1)+i[0,1) for complex floating point numbers;
S defaults to Float64. When only one argument is passed besides the optional rng and is a Tuple, it is interpreted as a collection of values (S) and not as dims.
For your example it would be
rand(1:30)
You can pass ranges to the rand
function to generate a number between two other numbers, included:
julia> rand(1:30)
24
julia> rand(1:30)
18