Day01. python

딥러닝을 학습 한 기록입니다. 1일차로 파이썬을 학습 하였습니다.

Day01. python
밑바닥부터 시작하는 딥러닝 1 | 사이토 고키 | 한빛미디어 - 예스24
딥러닝 분야 부동의 베스트셀러!머리로 이해하고 손으로 익히는 가장 쉬운 딥러닝 입문서이 책은 딥러닝의 핵심 개념을 ‘밑바닥부터’ 구현해보며 기초를 한 걸음씩 탄탄하게 다질 수 있도록 도와주는 친절한 안내서이다. 라이브러리나 프레임워크에 의존하지 않고 딥러닝의…

Download Success | Anaconda
Choose Your Download Windows Mac Linux Anaconda Distribution Complete package with 8,000+ libraries, Jupyter, JupyterLab, and Spyder IDE. Everything you need for data science. Windows 64-Bit Graphical Installer Miniconda Minimal installer with just Python, Conda, and essential dependencies. Install only what you need. Windows 64-Bit Graphical Installer Anaconda Distribution Complete package with 8,000+ libraries, Jupyter, […]
chmod +x Anaconda3-2025.12-1-MacOSX-arm64.sh
./Anaconda3-2025.12-1-MacOSX-arm64.sh

사용법

$ python3

인터프리터 진입 명령어

>>> (Ctrl + D)

인터프리터 탈출 단축키

문법

산술연산

$ python3
Python 3.14.3 (main, Feb  3 2026, 15:32:20) [Clang 17.0.0 (clang-1700.6.3.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 1-2
-1
>>> 4*5
20
>>> 7/5
1.4
>>> 3**2
9

자료형

$ python3
>>> type(1)
<class 'int'>
>>> type(1.1)
<class 'float'>
>>> type('h')
<class 'str'>
>>> type("hello world!!!")
<class 'str'>
>>> type(1 * 3.14)
<class 'float'>

변수

>>> x = 1
>>> y = 1.1
>>> a = [1,2,3,4,5]
>>> print(a)
[1, 2, 3, 4, 5]
>>> print(x)
1
>>> type(a)
<class 'list'>
>>> a[0]
1
>>> a[4]
5
>>> a[5]
Traceback (most recent call last):
  File "<python-input-17>", line 1, in <module>
    a[5]
    ~^^^
IndexError: list index out of range
>>> a[4] = x
>>> x = 2
>>> print(a)
[1, 2, 3, 4, 1]

리스트 접근

>>> print(a)
[1, 2, 3, 4, 1]
>>> a[1:3] # 인덱스 1~3 까지 '슬라이스'
[2, 3]
>>> a[2:] # 2 이상 '슬라이스'
[3, 4, 1]
>>> a[:3] # 3 미만 '슬라이스'
[1, 2, 3]
>>> a[:-1] # 인덱스 처음부터 마지막 -1 까지 '슬라이스'
[1, 2, 3, 4]
>>> a[-2:] # 인덱스 마지막 원소의 2 개 앞 까지 '슬라이스'
[4, 1]

딕셔너리

>>> obj = {'name':'pollra', 'age':33}
>>> obj['name']
'pollra'
>>> obj['age']
33
>>> print(obj)
{'name': 'pollra', 'age': 33}

bool

>>> isJava = False
>>> isPython = True
>>> type(isPython)
<class 'bool'>
>>> not isPython
False
>>> isJava and isPython
False
>>> isJava or isPython
True

if

>>> if isPython:
...     print('Hello, world!!!')
... else:
...     print('I\'m a teapot')
...
Hello, world!!!
  • 공백 중요(4개)
  • 공백 대신 탭을 써도 되지만 공식적으로는 공백을 권장하고 있음

for

>>> for i in [3,5,7,9]:
...     print(i)
...
3
5
7
9

함수

>>> def hello(value):
...     print('Hello, '+value)
...
>>> hello(1)
Traceback (most recent call last):
  File "<python-input-42>", line 1, in <module>
    hello(1)
    ~~~~~^^^
  File "<python-input-41>", line 2, in hello
    print('Hello, '+value)
          ~~~~~~~~~^~~~~~
TypeError: can only concatenate str (not "int") to str
>>> hello('Text')
Hello, Text

스크립트 작성

  • 파이썬 인터프리터 에서 프로그램 만드는건 불편
  • 스크립트 작성하여 파일 실행 하는 방식으로 개발 가능

클래스

  • self : Java 의 this 와 같음