Random numbers
Wed Feb 02 2022 04:13:24 GMT+0000 (Coordinated Universal Time)
Saved by
@marcpio
import random
# random(): random float between 0.0 and 1.0 (including 0.0 but not 1.0)
for i in range(10):
x = random.random()
print(x)
# randint() takes parameters low and high and returns an integer between low and high (including both)
random.randint(5, 20)
# to choose an element from a sequence at random:
t = ['a', 'b', 'c']
random.choice(t)
content_copyCOPY
Comments