Helen
0
Q:

random range python

>>> random.uniform(1.5, 1.9)
1.8733202628557872
11
# imports random
import random
# randint generates a random integar between the first parameter and the second
print(random.randint(1, 100))
34
from random import randint

print(randint(1,3))

#Possible Outputs#
#1
#2
#3
11
from random import randint

# generate an integer between 3 and 9 (inclusive range).
# (see randrange for exclusive range)
print(randint(3, 9))
8
import random

random.randint(lower, upper)
6
# 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
from random import randint

print(randint(3, 9))
6
# imports random
import random
# randint generates a random integar between the first parameter and the second
print(random.randint(1, 100))
# random generates a random real number in the interval [0, 1)
print(random.random())
19
# The random function random() returns a random float between
# zero and one
import random
random.random()
6
#import random 
import random

names = ['Harry', 'John', 'Smith', 'Larry']

#print random name from names
print(random.choice(names))

#print random integer in a range of numbers
print(random.randint(1, 100)
6
from random import randrange
print(randrange(10))
1

New to Communities?

Join the community