Day02. 튜플(Tuple)
Why Tuple?- 더 적은 메모리 사용- immutable이기 때문에 실수로 값이 바뀌지 않음 1) Tuple 생성하기1234567891011121314151617empty_tuple = ()print empty_tuple one_tuple = 'tuple1',another_tuple = ('tuple2',)more_tuple = ('a', 'b', 'c') print one_tupleprint another_tupleprint more_tuple ()('tuple1',)('tuple2',)('a', 'b', 'c') cs 2) Tuple unpacking1234567891011121314x = 1, 2, 3print x a, b, c = 1, 2, 3print a, b, c d, e, f = (1,..
Day02. 리스트 (List)
리스트와 튜플- 복수개의 값을 담을 수 있는 데이터 구조- 리스트는 생성후 변경 가능, 튜플은 생성후 변경 불가능 리스트 [a, b, c, d, e, c, a]튜플 (a, b, c, d)딕셔너리 {a:3, b:2, c:1}집합 set(a, b, c) 1. 리스트123456789empty_list1 = list()empty_list2 = [] print empty_list1print empty_list2 [][]cs 1) list() 함수 : 다른 데이터 타입을 리스트로 변환할 때 사용 1234567891011cat = 'cat'print type(cat)print list(cat)print list(cat)[1]print type(list(cat)) ['c', 'a', 't']acs 123456789te..
16. 단일행함수와 그룹함수
단일행함수와 그룹함수 - 단일행함수 : 행마다 함수가 적용되어 결과를 반환함 - 그룹함수 : 하나 이상의 행을 그룹으로 묶어 연산하여 총합, 평균 등 하나의 결과로 나타냄 ex) 30번 부서 소속 사원의 급여를 출력하는 쿼리문을 출력하시오. 단일행 함수 적용 select deptno, sal from emp where deptno=30 그룹 함수 적용 select deptno, sum(sal) from emp group by deptno having deptno=30 **그룹함수: sum, avg, count, max, min, stddev(표준편차), variance(분산) select deptno, sum(sal) as sum from emp group by deptno