More actions
No edit summary |
No edit summary |
||
| Line 1: | Line 1: | ||
= 수업자료 = | |||
코드 : https://github.com/gnidoc327/doctor_man | |||
책 : https://wikidocs.net/11 | |||
= 내용 = | = 내용 = | ||
== git을 써보자 == | == git을 써보자 == | ||
Revision as of 06:54, 1 May 2017
수업자료
코드 : https://github.com/gnidoc327/doctor_man 책 : https://wikidocs.net/11
내용
git을 써보자
- clone
- commit
- push
- pull
- gitignore
python
자료형
- 숫자
- 정수
- 실수
- 8진수
- 16진수
- 문자열
- 큰따옴표
- 작은따옴표
- 큰따옴표 x 3
- 작은따옴표 x 3
- \(백슬래시) - 이스케이프 코드
- 인덱싱
- 포매팅(formatting)
- 단순 : %
- 고오오오오급 : {}
- 리스트 - []
- 인덱싱
- 슬라이싱
- 추가/삭제(del)
- 튜플 - ()
- 리스트와의 차이점 : 값 수정 x
- 딕셔너리 - {'key': 'value'}
- 집합 - set
- 특정 : 중복 허용x, 순서x
- 교집합, 합집합, 차집합 가능
- 참/거짓
- 참 : 1, not None(데이터가 있으면 무조건 참)
- 거짓 : 0, None(데이터가 없으면 무조건 거짓)
- 변수
- 사실은 모든건 객체
- getrefcount - 참조 개수
- id - 메모리 주소값
- del - 메모리에서 변수 삭제
- copy
- is
연산자
- '+'
- 숫자 : 더하기
- 문자열 : 다른 문자열 연결
- 리스트 : 합치기
- '-'
- 숫자 : 빼기
- '*'
- 숫자 : 곱하기
- 문자열 : 해당 문자열 n회 연결
- 리스트 : n회 반복
- '**'
- n ** m = pow(n, m), n^m
- '%' : 나누기 나머지
- '//' : 나누기 몫
제어문
- if
- if
- elif
- while
- while
- break
- continue
- 무한 루프 탈출 - `Ctrl+C`
- for
- for in
- range
함수
- def 함수명(인수): return 리턴값
- 인수값이 여러개? - *args
- 인수 초기값 설정
- 함수 밖의 변수를 건들고 싶다!
- return
- global
입출력
- 입력 - input
- 출력 - print
가상환경
- virtaulenv - pycharm에서 해보자
- pip
- get-pip.py
- show
- list
- freeze
- install/uninstall
- -r
- -m
클래스
- class 클래스명:
- 클래스 첫글자는 대문자 = class Service, class Person
- self
- init
모듈
- import 모듈이름
- from 모듈이름 import 모듈함수
- main
- `if __name__ == "__main__":`
패키지
__init__.py
예외처리
try: except: pass except 발생오류 as 오류 메시지 변수: else: finally: def error(self): raise NotImplementedError
내장함수
- isinstance
- id
- input/print
- lambda
- len
- list
- str
- type
외장함수
- sys
- os
- time
- random
과제
- 내용
해당 클래스로 주어진 학생 리스트의 학점 평균을 내주는 모듈을 만들기
- 예시
calculator.py
class Calculator: @static def add(self, first, second): return first+second
calc_modult.py
students = [
("김한성", [{"C강의", "A+"}, {"창의적설계", "F"}, {"네트워크", "D"}]),
("고은진", [{"C강의", "C+"}, {"창의적설계", "A+"}]),
("박시현", [{"C강의", "B+"}, {"창의적설계", "B"}])
]
scores = [
{"A+": "4.5"},
{"A": "4"},
{"B+": "3.5"},
{"B": "3"},
{"C+": "2.5"},
{"C": "2"},
{"D+": "1.5"},
{"D": "1"},
{"F": "0"}
]
lectures = [
{"C강의": "3"},
{"창의적설계": "2"}
]
def showScore(self, students_input, scores_input)
코딩코딩~~~