로또 (1) 썸네일형 리스트형 Python Lotto Program Code1>import random lottonumber = random.sample(range(1, 46), 6) print(lottonumber) Code1 풀이>로또 번호는 가장 어찌보면 만들기 간단한 알고리즘이다.random 함수로 난수를 만들어서 무작위 추출법인 sampling 으로 처리하는 방식이다.이를 위해 Code 1은 random 함수안에 있는 sample 라는 함수를 불러들였다.또한 range 함수를 통해 로또의 범위인 1 ~ 45 / 그중 6개를 추출하는 형식으로 이루어진다. Code1 Output>[1, 21, 4, 24, 43, 18] Process finished with exit code 0 Code2>import random print('-' * 20) print('lotto.. 이전 1 다음