Answers for "how to generate random numbers python"

84

random number python

# generate random integer values
from random import randint

value = randint(0, 10)
print(value)
Posted by: Guest on February-15-2020
10

how to generate a random number python

import random
n = random.randint(0,22)
print(n)
Posted by: Guest on June-03-2020
8

python make a random number

# generate random integer values
from random import seed
from random import randint
# seed random number generator
seed(1)
# generate some integers
for _ in range(10):
	value = randint(0, 10)
	print(value)
Posted by: Guest on February-26-2020
11

python random number

from random import randint

print(randint(1,3))

#Possible Outputs#
#1
#2
#3
Posted by: Guest on March-07-2020
1

random number generator in python

import random

a = random.randint(0,10)
print(random.randint(0,a))
Posted by: Guest on January-12-2021
2

random numbers python

import numpy
x = numpy.random.randint(100)
# 63

x = numpy.random.randint(100, size=5)
# [60 50 55 30 88]

x = numpy.random.rand()
# 0.37588774033323125

x = numpy.random.rand(5)
# [0.41746837 0.67201216 0.55337301 0.51383033 0.21457139]

x = numpy.random.rand(2,3)
# [[0.19597024 0.65582147 0.3804617 ]
#  [0.5601902  0.5976546  0.58099592]]

x = numpy.random.choice([1,5,2,3,4])
# 3

x = numpy.random.choice([1,5,2,3,4], size=(2,3))
# [[2 4 1]
#  [3 3 3]]

import random
x = random.getrandbits(1)
# True
Posted by: Guest on October-03-2020

Code answers related to "how to generate random numbers python"

Python Answers by Framework

Browse Popular Code Answers by Language