※ Goal.
1. 파이썬 기본 문법 정리 (참조. Python for Data Analysis)
2. 파이썬 윈도우 개발환경
----------------------------------------
■ 윈도우 개발환경 구축
- 참고 : http://www.lucypark.kr/courses/tips/introduction-to-python.html#installing-python
- Anaconda 설치 : http://continuum.io/downloads#py34
■ 기본 문법 정리
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | ''' Created on 2015. 7. 11. @author: sbahn ''' if __name__ == '__main__': pass range_test = range(10) print(range_test) rangelist_test = list(range(10)) print(rangelist_test) """ Tuple : one-dimensional, fixed-length, immutable sequence of objects """ # basic tup = 4,5,5,6,5 print(tup) print(tup.count(5)) nested_tup = (4,5,6), (7,8) print(nested_tup[1]) # converting tup = tuple([1,2,3]) print(tup) tup = tuple('string') print(tup[3]) # concat tup = (4, None, 'foo') + (6, 0) + ('bar',) print(tup) tup = ('foor', 'bar') * 4 print(tup) # unpacking tup = (4,5,6) a,b,c = tup print(a,b,c) """ list : variable-length & conetnts can be modified """ # append # insert # pop # remove # concat, combine # sorting # binary search (bisect) import bisect c = [1, 2, 3, 2, 4, 5, 6] print(bisect.bisect(c, 3)) # slicing seq = [7, 2, 3, 7, 5, 6, 0, 1] print(seq) print(seq[1:5]) print(seq[::2]) print(seq[::-1]) """ built-in sequence function """ # enum # sorted # zip # reversed """ Dict (hash map, associative array) : Flexibly-sized collection of key-value pairs""" empty_dict = {'a' : 'some value', 'b' : [1,2,3,4]} print(empty_dict) """ Set : unordered collection of unique elements """ """ List, Set, Dict Comprehensions """ """ Functions """ def my_function(x, y, z=1.5): if z > 1: return z * (x + y) else: return z / (x + y) print(my_function(1,2)) # Namespaces, Scope, and Local Functions # Returning Multiple Values # Functions Are Objects # Anonymous (lambda) Functions # Closures: Functions that Return Functions # Extencded Call Syntax with *args, **kwargs # Currying: Partial Argument Application def add_numbers(x, y): return x + y add_five = lambda y: add_numbers(5, y) print("lamba currying : " + str(add_five(4))) # Generators """ Files and the Operation system """ | cs |