Day1
cloud → scale in out 시대
[Powershell에 입력]
Invoke-WebRequest -Uri "https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe" -OutFile ".\miniconda.exe"
Start-Process -FilePath ".\miniconda.exe" -ArgumentList "/S" -Wait
del .\miniconda.exe
환경 구축, anaconda 말고 miniconda 설치
C:\Users\rosie>python
Python 3.12.12 | packaged by Anaconda, Inc. | (main, Oct 21 2025, 20:05:38) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
mini 설치 후 cmd에서
conda install anaconda
지웠다 깔지 말걸. 환경변수가 꼬였다.
해결했다. 알고보니 전에도 미니콘다를 깔았던 것이다.
인간의 기억력이 이렇게나 간사하다.
b : 아래 만들기
a : 위에 만들기
dd : 삭제
m : markdown 으로 변경
y : code 변경
Ctrl + enter -> 현재 셀 실행
shift + enter -> 현재 셀을 실행하고 밑으로 이동
alt + enter -> 현재 셀을 실행하고 아래 셀을 생성
True, False…
리스트 , 문자열 모두 해당
indent…(들여쓰기를 이야기하나봄.)
딕셔너리 개념은 똑바로 하자!
json은 딕셔너리 형태. 그렇게 json을 많이 봐놓고 둘이 머리에서 연결되었던 적이 없다.
tmp2 = [x for x in range(1,11) if x%2==1]
print(tmp2)
# 변수를 왼쪽, 조건문을 오른쪽에.
리스트와 딕셔너리를 섞어서 사용하는 형태.
현재까지는 데이터 분석을 위해 데이터 값 뽑는 중.
데이터 타입을 중첩해서 쓰는 게 효율적이라는 걸 인지하고 있다.
gu_counts = {}
for s in star['list']:
gu_name = s['gugun_name']
if gu_name in gu_counts:
gu_counts[gu_name] +=1
else:
gu_counts[gu_name]=1
for gu, count in gu_counts.items():
print(f"{gu}:{count}")
import datetime
week_counts={}
for s in star['list']:
storeopen= s['open_dt']
storeopen= datetime.datetime.strptime(storeopen,'%Y%m%d').weekday()
if storeopen in week_counts:
week_counts[storeopen]+=1
else:
week_counts[storeopen]=1
for weekday, counts in week_counts.items():
print(f"{weekday} : {counts}")
Windows Subsystem for Linux
Day2
cmd에 pip 입력 시 가능한 command 리스트 출력됨
오늘은 selenium을 설치하였다.
pip install [package]
pip uninstall [package]
pip list
빅분기 준비할 때 나오는 꿀팁이 나오고 있다.
기능 보기 : dir()
함수 설명서 : help()
리스트 컴프리헨션으로 윤년 문제 풀이하기
leak_year = [year for year in range(1900, 2101) if (year % 4 == 0 and year % 100 != 0) or (year % 400 == 0)]
try:
text.index('엔코아')
except:
print("error")
print("hi")
큰 코드 돌려놓고 꺼지면 비통해짐.
예외 처리로 해결
예외 처리에 대한 직관력이 늘었다.
tuple[1]='abc' #오류 발생
list[1] = 'abc'
함수 내부 내에 있으면 지역 변수.
(lambda x, y : x+y)(10,20)
for key, val in gugun.items(): # 여기 적용되는 것이 unpacking
print(key,val)
sorted(gugun.items(), key= lambda x :x[1],reverse=True)
#type hint(강제성 없음)
def myfunc3(a : int, b : int):
return a+b
아 그래서 if문이 말이 짧았구나.
함수형 언어 → 함수의 결과를 또 함수가 받아내는 것
파이썬도 이와 같이 활용할 수 있음
함수형 언어의 장점 → 배달 사고 나지 않음.
애초에 url에 api로 데이터 옮기는 주소로 접근하는 방법이 있었다니 그 생각을 못했다.
web crawling 수업이 기대된다.
find를 존재여부 체크용으로 쓸 수 있다는 점이 깔끔하게 느껴짐
def get_code(company_name):
for com in krx['OutBlock_1']:
if com['ISU_ABBRV'].find(company_name)>-1:
return com['ISU_SRT_CD']
def get_code(company_name):
return [com['ISU_SRT_CD'] for com in krx['OutBlock_1'] if com['ISU_ABBRV'].find(company_name)>-1]
stock.py로 함수 묶어서 import로 내보내기
ord("H") # 16*4 = 64 +8
PS C:\skn> Format-Hex -Path "./a.txt"
경로: C:\\skn\\a.txt
00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
00000000 48 H
한글이 영어보다 용량이 크다.
## 전체 리딩
f1=open("./b.txt","r",encoding="utf-8") ## 용량 상관없이 전체를 읽어야함
## 줄마다 리딩
with open("./b.txt",'r',encoding='utf-8') as f: ## 한 줄씩 읽음 -> 메모리 이슈 상대적으로 적음
print(f.read())
이유 : 메모리를 사용할 때마다 allocate함
즉, 동시에 함수 적용 가능
' '.join(list(map(str,(x.values()))))
with open("./filelist.txt","w",encoding='utf-8') as f:
for roots, dirs, files in os.walk("c:/windows"):
for file in files:
print(f"{roots}/{file}")
파일 없으면 만들기
if not os.path.isdir("./stock"):
os.mkdir("./stock")
Day3
ipynb → interactibe python notebook
print의 기본 상태 ⇒ 엔터
end를 파라미터로 정해줄 수 있다
for x in range(1,11):
print(x, end='-')
사용과 동시에 할당 (3.8 이후부터 적용)
if a :=input("입력 : "):
print(a)
else:
print("입력이 없음")
아 귀엽다. 전에 본 적은 있는 것 같은데 사용해본 적이 없음
Pythonic → 파이썬스러운, 너무 짧게 쓰는.
import numpy
numpy.pi
자연상수 e 만들기
for x in range(1,1001,100):
print((1 + 1/x)**x)
## 자연상수 수렴시키는 걸 만들어보기
print("{:,}값 출력".format(19945232345678))
19,945,232,345,678값 출력
print("{:02d}값 출력".format(1))
01값 출력
url = "https://api.stock.naver.com/chart/domestic/item/{1}/day?startDateTime={2}&endDateTime={0}"
url.format('005930',202501010000,202512310000)
from datetime import datetime, date, timedelta
url = "https://api.stock.naver.com/chart/domestic/item/{}/day?startDateTime={}&endDateTime={}"
url.format('005930',datetime.now().strftime("%Y%m%d")+'0000',datetime.now().strftime("%Y%m%d")+'0000')
date(2026,12,24) - timedelta(days=100)
datetime.date(2026, 9, 15)
date.today()-date(2002,10,25)
datetime.timedelta(days=8470)
이만큼 살았음!!
import os
if not os.path.isdir("/test"):
os.mkdir('./test')
and, or → 선형 방정식으로 그리기 가능
xor → 인공지능의 겨울
제프리 힌튼의 해결…
선형에서 비선형으로 넘어가는 함수 → 활성화 함수
비선형 ⇒ LLM
numpy
scipy
matplotlib
seaborn
streamlit
scikit-learn
xgboost
tensorflow
pytorch
opencv
fastapi, django ,flask, qt5,6
,
airflow → 스케쥴 관리 → apache(무료 접근) airbnb
spark, database, linux, container,network
import sys
sys.version_info
sys.version_info(major=3, minor=12, micro=7, releaselevel='final', serial=0)
import sys
if sys.version_info.minor >=14:
print(200)
else:
raise ValueError("u need to version check")
a = [1,1.0,(lambda x : x**2)]
a.insert(2,'text') ## 특정 위치에 요소 삽입
[1, 1.0, 'text', <function main.(x)>]
b =[5,6]
a.extend(b)
[1, 1.0, 'text', <function main.(x)>, 5, 6]
a+=[7,8]
[1, 1.0, 'text', <function main.(x)>, 7, 8]
a = [1 , 1.0, (lambda x : x ** 2)]
a.insert(2, 'text')
b = [5,6]
a.extend(b)
a += [7,8]
c = a
c[-1]=1000
print(a)
[1, 1.0, 'text', <function at 0x0000021959EF02C0>, 5, 6, 7, 1000]
print(id(a)==id(c)) ## True
tmp = a.pop(-1) #1000
import this ## Tim peters가 sort 알고리즘 .. ^^
해피해킹, 허먼밀러
for문은 절대 2중까지만.
#n * n =n*2
for a in range(2,10):
if a ==3:
continue ## 3단만 돌아가지 않음
#break ## 3단 전에 멈춤
for b in range(1,10):
print(f"{a}X{b}={a*b}")
sum(map(lambda x : x==x[::-1],lyrics.split()))
딕셔너리 → 해시 값으로 구성되어있음
번호표 만들어주기 ^~^
for x in enumerate("안녕하세요"):
print(x) # 튜플로 출력
for i, x in enumerate("안녕하세요"):
print(i, x) # 언패킹돼서 출력
for _, x in enumerate("안녕하세요"):
print(_, x) #안쓰는 변수
tqdm → 시간 체크
from tqdm import tqdm
import time
for x in tqdm(range(100)):
time.sleep(1)
숟가락 얹기.
def my_deco(func):# 함수라는 자료형을 받음
def wraper():
print("wraper 실행")
func()
print("wraper 실행 이후")
print("my_deco 실행")
return wraper
@my_deco
def hi():
print("hi")
my_deco 실행
hi()
wraper 실행
hi
wraper 실행 이후
def repeat(num_times):
def decorator_repeat(func):
def wrapper(args):
for _ in range(num_times):
result = func(args)
return result
return wrapper
return decorator_repeat
@repeat(num_times=10)
def myprint(name):
print(f"바보,{name}")
myprint("알ㄹ야")
def myfunc(tmp, *a, **b):
print(tmp)
print(a)
myfunc(10, 1,2,3,4)
def myfunc(tmp, *a, **b):
print(tmp)
print(a)
print(b)
myfunc(10, 1,2,3,4, text ="5교시")
10
(1, 2, 3, 4)
{'text': '5교시'}
SAP → ERP 시스템 판매…시가총액 1위
a, b, *_ = (1,2,3,4)
_ 는 걍 쓰레기통에 넣어버림.
def myfunc(a,b=10,c): #오류남
print(a)
print(b)
print(c)
왜? 기본값 부여 시 뒤쪽부터 채워줘야 함.
DP 문제 해결 → 재귀 함수
def factorial(n):
output=1
for i in range(1, n+1):
output*=i
return output
def factorial(n):
if n==0:
return 1
else:
return n*factorial(n-1)
^~^
재귀함수는 내부적으로 stack에 더하여 연산
데이터 분석에 쓰이는 자료구조 → queue
데이터 손실 방지에 좋음.
코테 책 외우기…………?
H200 → 아주 좋은 클라우드 ^~^.
코테 → 디버깅 기능 꼭 활용.
정설 → 앨런 튜링이 먹은 사과의모양이 애플 마크……?
튜링 테스트(=이미테이션 게임)
애니악에 벌레 껴서 디버깅.
def fibo(n):
if n==1:
return 1
if n==2:
return 1
else:
return fibo(n-1)+fibo(n-2)
%%time #내부 명령어.
fibo(30)
CPU times: total: 141 ms
Wall time: 144 ms
832040
# 제너레이터, co-routine
def fib():
a,b=0,1
while True:
yield a # routine 짜는.
a,b = b, a+b
yield로 우선 기다리고, next 실행 때 넘김
%%time
fib_gen = fib()
first_10 = [next(fib_gen)for _ in range(40)]
CPU times: total: 0 ns
Wall time: 0 ns
+)
코딩테스트 → 암기에 가까움