반응형 난수생성2 [Python] 파이썬 난수 생성하기 / random 구문 import random 설명 파이썬의 라이브러리인 random 모듈을 이용하면 난수를 생성할 수 있습니다. random 모듈은 다양한 난수 생성 함수를 제공합니다. 난수 생성 함수로는 random.random(), random.uniform(a,b), random.randint(a,b), random.seed() 가 있습니다. 함수 설명 random.random() 0 이상 1 미만의 float 타입 난수를 생성해서 반환 random.uniform(a, b) a b 이면 b 이상 a 이하인 float 타입 난수를 생성해서 반환 random.randint(a, b) a 이상 b 이하인 int 타입 난수를 생성해서 반환 random.seed() 난수 생성기의 시드를 설정하여 항상 같은 난수 시퀀스를 .. 2023. 3. 9. [Javascript] 자바스크립트 난수생성, Crypto.getRandomValues() Crypto.getRandomValues() math.random() 대신, 더 강력한 수준의 암호화 난수 생성 방법이다. 매개변수로 제공한 배열을 전부 무작위 숫자로 채운다. 복사본 생성 없이 배열 자체가 변경된다. 암호화 키 생성 시에는 다른 함수를 사용해야 한다. 예시 const array = new Uint32Array(10); self.crypto.getRandomValues(array); console.log("오늘자 행운의 수:"); for (const num of array) { console.log(num); } 2018. 5. 28. 이전 1 다음 반응형