random1 [Python - Frequently Used Code] Random 패키지 random.random() : 0.0 이상 1.0 미만의 실수를 반환합니다.import random# 0.0 이상 1.0 미만의 난수 생성result = random.random()print(result) # 예: 0.7457397453918837 random.randint(a, b) : a 이상 b 이하의 정수(int)를 무작위로 반환합니다. 주의) 경계값 a, b가 포함됩니다.import random# 1 이상 10 이하의 정수 난수 생성result = random.randint(1, 10)print(result) # 예: 4 random.sample(population, k) : 주어진 리스트(population)에서 k개의 요소를 무작위로 비복원추출합니다.import random# 리스트에서.. 2024. 12. 18. 이전 1 다음 반응형