학습일 : 2020.01.24

학습목표

연습문제

  1. 로또 번호 자동 생성기(함수로)를 만드시오
  2. numpy를 이용하여 pi(원주율) 값을 계산하시오
**import** numpy **as** np
np.random.choice(np.arange(1, 46), size**=**6, replace**=False**)

Out[2]:

array([26, 6, 45, 32, 30, 33])

**def** generate_lotto_nums(): 
	**return** np.random.choice(np.arange(1, 46), size**=**6, replace**=False**) 

generate_lotto_nums()

Out[6]:

array([31, 43, 33, 20, 32, 39])

total **=** int(1e7)
points **=** np.random.rand(total, 2)

4 ***** np.sum(np.sum(points ****** 2, axis**=**1) **<** 1) **/** total

Out[7]:

3.1404064