목록2022/01 (70)
Developer_Neo
빈 문자열 만들기 빈따옴표 이용 str()함수이용 #빈따옴표 이용 s='' print(s) # 결과-> # 아무것도 안나옴 len(s) # 결과: 0 type(s) # 결과: >>> w = str( ) >>> print(w) >>> len(w) 0 >>> type(w) 빈 리스트만들기 빈 대괄호 이용 list()함수이용 >>> a = [] >>> print(a) [] >>> type(a) >>> b = list() >>> print(b) [] >>> type(b) 빈 튜플만들기 빈 소괄호 이용 tuple()함수이용 >>> a=() >>> print(a) () >>> type(a) >>> b=tuple() >>> print(b) () >>> type(b) 빈 사전만들기 빈 중괄호 이용 dict()함수이용 ..
인덱싱(indexing) - 시퀀스 자료형인 문자열, 리스트, 튜플에 사용가능 - 시퀀스 자료형에 부여된 번호를 의미한다. 특징 양수 인덱스 앞에서부터 시작하는 것으로 0부터 시작 음수 인덱스 뒤에서부터 시작하는 것으로 -1부터 시작 문자열 a = 'hello' print(a[0]) # 결과 값: h print(a[1]) # 결과 값: e print(a[2]) # 결과 값: l print(a[3]) # 결과 값: l print(a[4]) # 결과 값: o print(len(a)) # 결과 값: 5 0 1 2 3 4 h e l l o -5 -4 -3 -2 -1 - 양수 인덱스의 맨 마지막은 len(a)-1 이라고 할 수 있고 음수인덱스의 맨 앞은 -len(a)라고 할 수 있다. 리스트 >>> s = 'sh..
print함수 - 출력을 담당하는 것 - 반환값이 없다 따라서 None을 출력한다. >>> y=print('hello') hello >>> print(y) None print함수의 sep, end 옵션 - 구분자(sep)의 디폴트값은 공백이다. - end옵션의 디폴트 값은 개행(줄바꿈)이다 print("hello") # 결과->hello # end옵션의 디폴트 값은 개행 print("a") print("b") ''' 결과 a b ''' # sep옵션의 디폴트 값은 띄어쓰기(공백) print("a", "b", "c") # 결과->a b c # print("문자열", sep 옵션, end 옵션) 형식 print('python', end="_") print('print', end="_") print('end옵..
파이썬의 아홉 가지 자료형 분류 자료형 특징 예 수치 자료형 정수 -3,-2,-1,0,1,2,3 실수 3.14 , 5.5 , 8.0 0.54, -3.89 복소수 3+4j, 5.7+2J , 5+j 부울 자료형 부울 True, False 군집형태 자료형 (컨테이너 자료형) 시퀀스 자료형 문자열 'hello', "python" 리스트 [1,2,3,4], ['red', 'blue'] 튜플 (1,2,3,4), ('red', 'blue') 집합 오름차순으로 정렬됨 기호는 {} {1,2,3}, {'red', 'blue'} 사전 기호 {key: value} {'one': 1, 'two' :2} mutable vs immutable mutable 자료형 - 변경 가능한 자료형 immutable 자료형 - 변경 불가능한 ..
파이썬은 인터프리터가 필요한 언어이다. 이외의 인터프리터가 필요한 언어는 자바스크립트, 파이썬, 루비, sql,... 컴파일러는 C, C++, C#, Go,...에 쓰인다. 자바는 컴파일러와 인터프리터 모두 사용 컴퓨터는 모든 명령을 0과 1로 이해하여 CPU가 처리하고 실행한다. 그래서 우리의 언어인 한글이나 영어는 이진코드로 해석하고 명령을 처리한다 따라서 우리의 언어로 친 코드들을 컴퓨터가 이해할 수 있게 번역해주는 번역기가 필요한데 이 번역기가 인터프리터, 컴파일러이다. 즉 둘 다 고레벨 언어로 작성된 프로그래밍 언어를 기계어로 번역하는 것은 공통점이다. 컴파일러는 전체 소스코드를 보고 명령어를 수집하고 재구성하지만 인터프리터는 소스코드의 각 행을 연속적으로 분석하며 실행한다.( 명령을 한 줄 씩..
git이 설치가 되어있다는 가정하에 시작하겠다. git이 설치가 되어있고 로그인까지 마쳤다면 밑이 과정으로 하면 된다. 1. Github홈페이지에서 repository를 생성한다. 2. git bash를 실행시켜 리눅스명령어인 cd 폴더경로를 이용해서 깃헙에 업로드할 파일이 있는 폴더로 이동 $옆에 명령어를 입력하면 된다. EX) cd /D/example 3. git init을 입력해 git이 추적할 수 있도록 .git 폴더를 생성한다. git init 4. git status로 unpacked된 것들이 있나 확인한다. git status 5. 우리는 처음으로 Github에 올릴 과정이니 git add . 를 입력하여 해당폴더안있는 모든 파일을 local repository에 추가한다. 6. commit..