22
Doing Math with Python Ch.01 숫숫 , 숫숫 윤윤윤 ([email protected])

Doing math with python.ch01

Embed Size (px)

Citation preview

Page 1: Doing math with python.ch01

Doing Math with PythonCh.01 숫자 , 연산

윤석준 ([email protected])

Page 2: Doing math with python.ch01

파이썬으로 풀어보는 수학

상세설명https://github.com/DevStarSJ/Study/blob/master/Blog/Python/DoingMathWithPython/DoingMathWithPython.Ch01.ipynb

• 원서명 : Doing Math with Python: Use Programming to Explore Algebra, Statistics, Calculus, and More! (ISBN 9781593276409)

• 지은이 : 아미트 사하 (Amit Saha)• 원서 및 관련자료 : https://www.nostarch.com/doingmathwithpython• 번역서 : http://www.acornpub.co.kr/book/doing-math-with-python

Page 3: Doing math with python.ch01

3

1. 사칙연산 1.1 기본연산 ( 더하기 , 빼기 , 곱하기 )

Page 4: Doing math with python.ch01

4

1. 사칙연산 1.2 나누기 ( 나누기 , 나머지 )

Page 5: Doing math with python.ch01

5

1. 사칙연산 1.3 지수

Page 6: Doing math with python.ch01

6

2. 분수 fractions 모듈의 Fraction 클래스를 사용 Fraction( 분자 , 분모 ) 로 생성

Page 7: Doing math with python.ch01

7

3. 복소수 (Complex number) 3.1 생성

문자 j 또는 J 를 사용하여 허수부 입력

complex 객체를 이용해서 생성

Page 8: Doing math with python.ch01

8

3. 복소수 (Complex number) 3.2 연산 ( 덧셈 , 뺄셈 )

Page 9: Doing math with python.ch01

9

3. 복소수 (Complex number) 3.3 연산 ( 곱셈 )

Page 10: Doing math with python.ch01

10

3. 복소수 (Complex number) 3.4 연산 ( 나눗셈 )

분모의 컬레복소수를 분모 , 분자에 모두 곱하여 유도 나머지 % 와 버림은 // 은 제공하지 않음

Page 11: Doing math with python.ch01

11

3. 복소수 (Complex number) 3.5 컬레복소수 (conjugate)

같은 실수부에 허수부의 부호가 반대인 경우 .conjugate() 멤버함수를 이용

Page 12: Doing math with python.ch01

12

3. 복소수 (Complex number) 3.6 복소수의 값 (magnitude)

절대치 함수 ( abs() ) 를 이용해서 구할 수 있음

계산공식 : ( 실수부 제곱 + 허수부 제곱 ) 의 제곱근 ( 루트 )

Page 13: Doing math with python.ch01

13

4. Factor 4.1 팩터 (Factor) 란 ?

0 이 아닌 다른 정수 a 를 b 로 나누었을 때 나머지가 0 인 경우 a 는 b 의 팩터라 함

Page 14: Doing math with python.ch01

14

4. Factor 4.2 모든 팩터 (Factor) 구하기

그보다 작은 모든 양의 정수에 대해서 검사를 수행

Page 15: Doing math with python.ch01

15

5. 측정 단위 변화 센티미터 to 인치 : 1 inch = 2.54

cm

마일 to 킬로미터 : 1 mile = 1.609 km

화씨 to 섭씨 : C = (F - 32) * 5 / 9

섭씨 to 화씨 : F = (C * 9) / 5 + 32

Page 16: Doing math with python.ch01

16

6. 이차방정식 근 구하기 다음 2 차 방정식의 근을 구하는 것을 파이썬으로 표현

Page 17: Doing math with python.ch01

프로그래밍 연습문제필자가 풀이한 답은 다음 Link 를 참고하세요 .https://github.com/DevStarSJ/Study/blob/master/Blog/Python/DoingMathWithPython/DoingMathWithPython.Ch01.ipynb저자의 정답은 다음 Link 에 있습니다 .https://www.nostarch.com/doingmathwithpython

Page 18: Doing math with python.ch01

18

1. 짝수 , 홀수 자판기

입력한 숫자가 짝수인지 홀수인지 출력합니다 . 입력한 숫자 다음으로 오는 짝수 또는 홀수를 같이 출력합니다 . is_integer() 를 이용하여 유효하지 않은 입력에 대해서는 오류 메세지를 출력하세요 .

Page 19: Doing math with python.ch01

19

2. 개선된 곱 테이블 X 단을 Y 개까지 출력하는 방식으로 구현하세요 .

Page 20: Doing math with python.ch01

20

3. 개선된 단위 환산 아래 변환이 모두 가능한 프로그램을 작성하세요 .

거리 ( 킬로미터 <-> 마일 ) 무게 ( 킬로그램 <-> 파운드 ) 온도 ( 섭씨 <-> 화시 )

Page 21: Doing math with python.ch01

21

4. 분수계산기 2 개의 분수를 입력받아서 , 사칙연산을 수행하는 프로그램을 작성하세요 .

Page 22: Doing math with python.ch01

Thanks