help() :
-m = —module : start module.
module = py file.
ex) -m unittest ⇒ -m unittest.py ⇒ -m {absolute path of unittest.py}
pip install pandas ⇒ python pip install {absolute path of pandas.py}
we usually use abbreviation command, there always has absolute path
pycharm multi cursor = alt + j
pycharm shift file = ctrl + shift + n
indent

version notation
major
python 3.x.x
major = sys.version_info.major
minor
python 3.11.x
minor = sys.version_info.minor
pass ⇒ ellipsis( . . . )
variable
function() → meaning call function
print(function)
in function or method if print it removing (), print start position by memory adress
print(id(function))
if print it having (), print uniq id that assign element in ()
Q. why thaere has no type declaration in python ?
A. python interpreter guess the type of variable itself.
But we can ‘type hint’ (inform explicitly to interpreter) in function or method.
python is dynamic type langauge.
type casting : python intermreter change type appropriately.
💡 make python package named ‘sec03’llama3, ollama
💡 1. install ollama 2. window trminal : ollama pull llama3 ollama run llama3branch statement
loop statement
fruits = ["apple", "pair"]
for fruit in fruits:
print(f'fruit name is {fruit}')
for i in range(0, len(fruits)):
print(f'{i} fruit name is {fruits[i]}')
# most pythonic code. enumerate makes tuple data.
for idx, fruit in enumerate(fruits):
print(f'{idx} fruit name is {fruit}')
chars = 'word'
for count, char in enumerate(chars):
print(f'{count} character is {char}')foreach plural as singular {
singular ~~~
}n = 0
while n < 3:
print(f'variable n is (n)')
n += 1 jump statement
get grade function
def get_grade(grade):
if grade >= 90:
return "A"
elif grade >= 70:
return "B"
elif grade >= 50:
return "C"
else:
return "D"
import exam.exam
from exam.exam import *
# 파이썬은 진입 점이 따로 없기 때문에
# 파이썬 인터프리터가 이 파일을 직접 실행시키면 이라는 뜻. 여기 부터 프로그램이 시작.
if __name__ == "__main__":
print("Input your grade (0-100): ")
grade = float(input())
result = exam.exam.get_grade(grade)
print(result)
True = on = electrified
False = off = not electrified
len() : input countable object, retrurn number people count. ( 1 ~ )
countable object, container object
docker, django, rest + react, pitcher(in model)
input must be equal to model’s pitch ? training pitch ?
None type : meaning empty
not True == False
1-term operator
binary operator
ternary operator
data structure
pythonic = readable, sppedy
scope
formatting
for i in range(1, 10):
print(f"Multiplication table of {i}:")
for j in range(1, 10):
result = i * j
print(f"{i} x {j} = {result}")
print()for i in range(1, 10):
print(f"Multiplication table of {i}:")
for j in range(1, 10):
result = i * j
print("{} * {} = {}".format(i, j, result))
print()for i in range(1, 10):
print(f"Multiplication table of {i}:")
for j in range(1, 10):
result = i * j
print("{} * {} = {}".format(i, j, str(result).zfill(2)))
print()destructive method vs non-destructive method
shallow copy vs deep copy
signiture
expression
statement
exception handling
try:
import akfnsdf # there has no module named like that
except Exception as e:
print(e)
finally:
# What to do regardless of exceptions
print(e)
preprocessing vs post processing
Exception hierarchy
from io import UnSupportedOperation
get UnSupportedOperation class in io.py file
raise() : make error on purpose. then go to sys.exit().
# with : auto close
with open('some.txt', 'w') as f:
print(f.read)
print(f.readlines)
print(f.readline)
f.write('some.txt')
f.write('ssajfbs')