Python
-
[Python] - Closure개발/Python 2022. 7. 28. 20:59
Closure 1. Nested functions A function that is defined inside another function is known as a nested function. Nested functions are able to access variables of the enclosing scope. In Python, these non-local variables can be accessed only within their scope and not outside their scope. But Closure can be access non-local variables #nested function example def nested_func(text): temp = text def te..
-
[Python] - First class functions개발/Python 2022. 7. 28. 17:55
1. First class Obejct Define 1. You can store them in Variable , Data Structure(list,dictionary .. ) 2. You can pass the function as a parameter to another function 3. You can return the function from a function. 2. First class functions Python support first class functions, it means function is instance of Object. First class functions includes First class Object properties. First class functio..
-
[Python] - Generator개발/Python 2022. 7. 28. 16:38
Generator Generator functions allow you to declare a function that behaves like an iterator, it can be used in a for loop. Generator call like iterator whenever you need 1. yield if use normal function 'return' get value , but Generator use 'yield' yield can be used to control the iteration behaviour of a loop instead of building an array containing all the values and returning them all at once,..
-
[Python] - Call by Object reference & Call by sharing개발/Python 2022. 7. 28. 15:08
1. Call by value call by value used to C programming call the function , parameter copied value and pass value arguement so, do not changed origin data within function 2. Call by reference (pointer) call by reference used to Java programming parameter copied reference = pointer (value address) so, function can access origin data by address 3. Call by object reference( Call by sharing ) Python's ..
-
[Python] - Counter개발/Python 2022. 7. 27. 20:24
Counter A Counter is a dict subclass for counting hashable objects. collection where elements are stored as dictionary keys and their counts are stored as dictionary values. Syntax Counter([iterable-or-mapping]) from collections import Counter c = Counter('gallahad') > Counter({'a': 3, 'l': 2, 'g': 1, 'h': 1, 'd': 1}) c = Counter({'red': 4, 'blue': 2}) > Counter({'red': 4, 'blue': 2}) c = Counte..
-
[Python] - Permutation & Combination개발/Python 2022. 7. 27. 19:50
Permutation process of changing the linear order of an ordered set support itertools Permutations differ from combinations , which are selections of some members of a set regardless of order set {1, 2, 3} -> (1, 2, 3), (1, 3, 2), (2, 1, 3), (2, 3, 1), (3, 1, 2), (3, 2, 1) Syntax permutations(iterable, r=None) from itertools import permutations list( permutations('ABC', 2) ) > [('A', 'B'), ('A', ..
-
[Python] - N진수 표현 및 Ascii개발/Python 2022. 7. 27. 18:07
Python 진법 변환 1. N Base -> 10 Base value is A number or a string that can be converted into an integer number base is A number representing the number format. Default value − 10 Syntax - int(value, base) # N base to 10 base print(int('101',2)) > 5 print(int('202',3)) > 20 print(int('ADF',16)) > 2783 2. 10 Base -> 2 / 8 / 16 Base bin(), oct(), hex() function support # 2base print(bin(11)[2:]) > 10..
-
[Python] - Regular expression개발/Python 2022. 7. 27. 17:29
Regular Expression 1.meta characters . ^ $ * + ? { } [ ] \ | ( ) 1.1) character class [] regular expression between [ and ] is matching characters '-' operator mean From - To ( [0-5] -> [012345] ) '^' operator mean Not '.' operator mean all characters except \n '*' operator mean repeat characters 0~N ( N maybe 2000000000 because memory limit ) '+' operator mean repeat characters 1~N {m,n} operat..