[파이썬 Python] 랜덤 함수
·
Python
파이썬에서는 random 라이브러리를 사용할 수 있습니다. from random import * print(random()) # 0.0 ~ 1.0 미만의 임의의 값 생성 위처럼 random()를 실행하면 0.0 ~ 1.0 미만의 난수를 랜덤으로 출력해줍니다. from random import * print(random() * 10) # 0.0 ~ 10.0 미만의 임의의 값 생성 print(int(random() * 10) # 0 ~ 10 미만의 임의의 값 생성 print(int(random() * 10) + 1) # 1 ~ 10이하의 임의의 값 생성 random() 함수를 통해 복권 번호 자동 뽑기 print(int(random() * 45) + 1) # 1 ~ 45 이하의 임의의 값 생성 print(i..