νμ΄μ¬μμ λμλ₯Ό λ°μμν€κΈ° μν΄ μ¬μ©.
λλ€ λͺ¨λμ import νλ€.
import random
random.random()
0.0 <= x < 1.0 μ¬μ΄μ λλ€ν μ€μ
random.uniform(a, b)
a<= x <= b μ¬μ΄μ λλ€ν μ€μ
random.randint(a, b)
a<= x< b μ¬μ΄μ λλ€ν μ μ
random.randrange(a, b)
a<= x< b μ¬μ΄μ λλ€ν μ μ
random.randint(a, b)
a<= x <= b μ¬μ΄μ λλ€ν μ μ
random.choice(seq)
seq μ€ λλ€μΌλ‘ κ³ λ₯Έ νλμ μμ
random.sample(deq, n)
seq μ€ nκ°μ λλ€ν μμλ€μ λ°°μ΄μ 리ν΄
random.shuffle(seq)
seqκ° λλ€μΌλ‘ μμ΄μ λ°κΏλ²λ¦°λ€! λ°ν κ°μ None
import random
print(random.random()) # 0.8999159382861155
print(random.uniform(1, 5)) # 1.4874879446752813
print(random.randint(1, 5)) # 5
print(random.randrange(1, 5)) # 4
arr = ['a', 'b', 'c', 'd', 'e']
print(random.choice(arr)) # d
print(random.sample(arr, 2)) # ['b', 'd']
print(random.shuffle(arr)) # None
print(arr) # ['c', 'b', 'e', 'd', 'a']