Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python random number

import random
# Random number, 0 through 10, INCLUDING 10:
print(random.randint(0, 10))

#Random number, 0 through 10, NOT INCLUDING 10:
print(random.randrange(0, 10))

#Random choice from a list:
my_list = ["Apples", "Oranges", "Watermelon", "Pineapple", "Grapes"]
print(random.choice(my_list))

# Set a custom seed of 10 for random to work with:
random.seed(10)
Source by elearning.wsldp.com #
 
PREVIOUS NEXT
Tagged: #python #random #number
ADD COMMENT
Topic
Name
4+7 =