Eric M.
0
Q:

random float python

>>> random.uniform(1.5, 1.9)
1.8733202628557872
11
from random import randint

print(randint(1,3))

#Possible Outputs#
#1
#2
#3
11
import random
print(random.random(1, 10)) # any int or float
1
# To create a list of random float numbers:
import numpy
random_float_array = numpy.random.uniform(75.5, 125.5, 2)
# Output:
# [107.50697835, 123.84889979]
3
# The random function random() returns a random float between
# zero and one
import random
random.random()
6
#In contrast to randInt .random.uniform generates a floating number between two variables
# imports random
import random
# randint generates a random integar between the first parameter and the second
print(random.randint(1, 100))
4
from random import randint # Import randint from random
print(randint(1,20)) # Gets random number from first parameter to the second
0

New to Communities?

Join the community