로보테크AI

융합_로보테크 AI 자율주행 로봇 개발자 과정-26/01/05

steezer 2026. 1. 5. 18:30

현재까지 해봤던 프로젝트 설명

(CJ 해커톤 + ABC 부트캠프 + 졸업 논문(모델 이름 까먹어서 설명 제대로 못함))

네이버 연봉계산기 완성

import csv

NON_TAXABLE = 2_400_000          # 연 비과세액
NATIONAL_PENSION_CAP = 286_650  # 국민연금 월 상한

def cut_10_won(value):
    return int(value // 10 * 10)

def load_tax_table(path):
    table = []

    with open(path, newline="", encoding="utf-8") as f:
        reader = csv.reader(f)
        for row in reader:
            cleaned = []
            for cell in row:
                cell = cell.strip().replace(",", "").replace('"', "")
                cleaned.append(None if cell == "-" else int(cell))
            table.append(cleaned)

    fix_outlier(table)
    return table

def fix_outlier(table):
    #(r, c)를 기준으로 3x3 영역의 8방향 이웃 값을 사용해 이상치 1개를 평균값으로 대체
    rows = len(table)

    for r in range(1, rows - 1):
        for c in range(2, len(table[r]) - 1):
            if table[r][c] is None:
                neighbors = []

                for dr in (-1, 0, 1):
                    for dc in (-1, 0, 1):
                        if dr == 0 and dc == 0:
                            continue

                        nr, nc = r + dr, c + dc
                        if (
                            0 <= nr < rows and
                            0 <= nc < len(table[nr]) and
                            table[nr][nc] is not None
                        ):
                            neighbors.append(table[nr][nc])

                if len(neighbors) == 8:
                    table[r][c] = sum(neighbors) // 8

def find_income_tax(monthly_salary, dependents, tax_table):
    salary_unit = monthly_salary // 1000

    for row in tax_table:
        start, end = row[0], row[1]
        if start <= salary_unit < end:
            index = min(dependents - 1, len(row) - 3)
            return row[2 + index] or 0

    return 0

def salary_calculator(salary_annual, dependents, tax_file="tax.txt"):
    tax_table = load_tax_table(tax_file)

    # 총 월급 (실수령 계산 기준)
    gross_monthly = salary_annual // 12

    # 과세 월급 (공제 계산 기준)
    taxable_annual = salary_annual - NON_TAXABLE
    taxable_monthly = taxable_annual // 12

    # 4대 보험
    national_pension = min(taxable_monthly * 0.0475, NATIONAL_PENSION_CAP)
    health_insurance = taxable_monthly * 0.03595
    long_term_care = health_insurance * 0.1314
    employment_insurance = taxable_monthly * 0.009

    # 절사 기준
    national_pension = int(national_pension)
    health_insurance = cut_10_won(health_insurance)
    long_term_care = cut_10_won(long_term_care)
    employment_insurance = cut_10_won(employment_insurance)

    # 세금
    income_tax = find_income_tax(taxable_monthly, dependents, tax_table)
    income_tax = cut_10_won(income_tax)
    local_income_tax = cut_10_won(income_tax * 0.1)

    # 월 공제 합계
    monthly_deduction = (
        national_pension +
        health_insurance +
        long_term_care +
        employment_insurance +
        income_tax +
        local_income_tax
    )

    # 실수령
    monthly_net = gross_monthly - monthly_deduction
    annual_net = monthly_net * 12

    return {
        "국민연금": national_pension,
        "건강보험": health_insurance,
        "요양보험": long_term_care,
        "고용보험": employment_insurance,
        "근로소득세": income_tax,
        "지방소득세": local_income_tax,
        "연 실수령액": annual_net,
        "월 실수령액": monthly_net,
    }

# 실행
annual_salary = int(input("세전 연봉 입력: "))
dependents = int(input("부양가족 수 입력: "))

result = salary_calculator(annual_salary, dependents)

print("\n[네이버 연봉계산기 기준 출력]")
print(f"국민연금      : {result['국민연금']:,} 원")
print(f"건강보험      : {result['건강보험']:,} 원")
print(f"요양보험      : {result['요양보험']:,} 원")
print(f"고용보험      : {result['고용보험']:,} 원")
print(f"근로소득세     : {result['근로소득세']:,} 원")
print(f"지방소득세     : {result['지방소득세']:,} 원")
print(f"년 예상 실수령액: {result['연 실수령액']:,} 원")
print(f"월 환산금액    : {result['월 실수령액']:,} 원")

세전 연봉 입력: 30000000
부양가족 수 입력: 1

[네이버 연봉계산기 기준 출력]
국민연금      : 109,250 원
건강보험      : 82,680 원
요양보험      : 10,860 원
고용보험      : 20,700 원
근로소득세     : 29,160 원
지방소득세     : 2,910 원
년 예상 실수령액: 26,933,280 원
월 환산금액    : 2,244,440 원

 

4열 351행 406710 이상값


제너레이터: 이터레이터 직접 만들 때 사용, 함수 내부에 yield 키워드 사용하면 해당 함수는 제너레이터 함수가 되며, 일반 함수와 달리 함수를 호출해도 함수 내부 코드가 실행되지 않음

 

제너레이터 객체와 next()함수

제너레이터: 한줄씩 / 메모리 효율


스택, 힙

기본 자료형: 가볍고 정형화된 자료형

스택: 기본 자료형이 정리되어 있는 공간(상자)

객체 자료형: 무겁고 크기 정형화 되지 않은 자료형

힙: 객체 자료형이 정리되어 있는 공간(창고), 너무 커서 찾기 힘듦

리스트와 딕셔너리 같이 큰 자료형을 힙에 넣고 스택에 기록

주소, 레퍼런스: 창고의 어떤 위치에 저장했는지, 16진수 숫자로 표현

전역 스택: 가장 외각에 있는 스택

 

각 스택에 들어있는 변수는 완전 별개

함수를 호출한 쪽에서 값을 외치고 이를 함수 쪽에서 받아적는 느낌

 

기본 자료형 복사

스택   |   힙

change(전역) | func change

a ㄴ10

change func(함수)

b

a=10, b=20 -> 변경 안됨

불변 데이터(숫자, 문자)

ㄴreplace

안녕하세요 -> a안녕하세요 /새로운 칸 생성

a| 안녕하세요

b| a안녕하세요

리스트, 딕셔너리 -> 가변 데이터

주소는 스택

 

py -> 객체

obj -> heap

10 -> obj -> heap

 

스택 | 힙

        | [1, 2, 3]

스택엔 메모리의 위치만 저장

 

메모리에서 움직이는 것에 따라 파괴/비파괴 구분

 

5장 함수 확인문제

numbers = [1,2,3,4,5,6]
print("::".join(map(str, numbers)))
numbers = list(range(1, 10 + 1))
print("# 홀수")
print(list(filter(lambda x: x % 2 == 1, numbers)))
print()
print("# 3이상 7미만")
print(list(filter(lambda x: 3 <= x < 7, numbers)))
print()
print("# 제곱해서 50미만")
print(list(filter(lambda x: x**2 < 50, numbers)))

하노이 탑(재귀함수 연습)

def hanoi(n, start, temp, end):
    if n == 1:
        print(f"{start} → {end}")
        return

    hanoi(n - 1, start, end, temp)
    print(f"{start} → {end}")
    hanoi(n - 1, temp, start, end)

def move_count(n):
    return (1 << n) -1
n = int(input("원판 개수 입력: "))

print(f"\n[하노이 탑 이동 과정] (원판 {n}개)")
hanoi(n, "A", "B", "C")

print(f"\n이동 횟수: {move_count(n)}")

 

구문 오류와 예외

try except 구문

 

구문 오류: 실행 전 발생 오류

런타임 오류(예외): 실행 중 발생 오류

 

try:

    예외가 발생할 가능성이 있는 코드

except:

    예외가 발생했을 때 실행할 코드

else:

    예외가 발생하지 않았을 때 실행할 코드

finally:

    무조건 실행할 코드

 

pass#문법 오류 방지 목적-빈칸 대신 채워 넣는 키워드

 

가능한 구문 조합

try + except

try + except + else

try + except + finally

try + except + else + finally

try + finally

 

try:

    예외가 발생할 가능성이 있는 구문

except 예외의 종류 as 예외 객체를 활용할 변수 이름:

    예외가 발생했을 때 실행할 구문

 

except 구문을 if 조건문 처럼 사용해서 예외 구분

여러가지 예외가 발생할 수 있는 코드

raise 키워드: 일부로 예외를 발생시켜 프로그램을 죽게 만들어 잊지 않도록 하는 것

raise 예외 객체

 

raise 구문 사용 예시

https://github.com/tensorflow/tensorflow

 

GitHub - tensorflow/tensorflow: An Open Source Machine Learning Framework for Everyone

An Open Source Machine Learning Framework for Everyone - tensorflow/tensorflow

github.com

 

모듈

import 모듈 이름

from 구문

from 모듈 이름 import 가져오고 싶은 변수 또는 함수

import 모듈 as 사용하고 싶은 식별자

urlib 모듈: 네트워크 자원 위치 확인

텍스트 데이터 | 바이너리 데이터

구분 방법: 텍스트 에디터로 열었을 때 읽기 가능 | 불가능

장점: 사람이 쉽게 읽음, 편집 가능 | 용량 작음

단점 용량 큼 | 사람이 쉽게 읽을 수 없음, 편집 불가능

 

260105.py
0.00MB
260105_hanoi.py
0.00MB