pandas, matplotlib, seaborn 등)⚠️ Jupyter, Colab에서 RUN 버튼 남발 금지! 셀 실행 시 주의!
문자열.upper())'hello'.capitalize() # 'Hello'
str, list, tuple, rangename = "Alice"
print(f"Hello, {name}!")
text = "Python"
print(text[2:4]) # 'th'
print(text[::-1]) # 'nohtyP'
print(text[0:5:2]) # 'Pto'
replace(old, new[, count])strip([chars])split(sep, maxsplit)'구분자'.join(iterable)L = [1, 2, 3]
L.append(4)
L.extend([5, 6])
L.pop()
L.reverse()
L.sort()
t = (1, 2, 3)
list(range(1, 10, 2)) # [1, 3, 5, 7, 9]
d = {'name': 'Alice', 'age': 25}
d.get('name')
d.keys()
d.values()
d.items()
d.pop('age', None)
s = set([1, 2, 3])
s.add(4)
s.remove(1)
s1 | s2 # 합집합
s1 & s2 # 교집합
s1 - s2 # 차집합
a = [1, [2, 3]]
b = a[:]
b[1][0] = 999
print(a) # 내부 리스트는 공유됨
import copy
a = [1, [2, 3]]
b = copy.deepcopy(a)
print(3 + 5.0) # 8.0
print(True + 2) # 3
print(int("10")) # 10
+, -, *, /, //, %, **==, !=, is, is notand, or, notin, not inif condition:
pass
elif another:
pass
else:
pass
for i in range(5):
print(i)
while True:
break
squares = [x**2 for x in range(5)]
def greet(name):
return f"Hello, {name}"
greet("Alice")
*args, **kwargs 사용 가능lambda 함수도 가능def func(*args, **kwargs):
print(args)
print(kwargs)
len(), max(), min(), sum(), sorted()map(), zip(), enumerate()add = lambda x, y: x + y
print(add(2, 3)) # 5
nonlocal, global 필요