Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python random number

### random number between 0 and 0.99999
print(random.random())

### random number between 5 and 8
print(random.uniform(5,8))

### random number with normal distribution (bell curve)
## random.normalvariate(standard deviation sigma)
print(random.normalvariate(5, 0.1))

### simulate dice roll
print(random.randint(1,6))

### random item from list
number = ['one', 'two', 'three']
print(random.choice(number))
Source by www.python-lernen.de #
 
PREVIOUS NEXT
Tagged: #python #random #number
ADD COMMENT
Topic
Name
4+6 =