파일·폴더·버전·노트북과 스크립트Files, folders, versions, notebooks and scripts
경로와 바이트에서 실제 실행·변경 기록·원행 대응까지From paths and bytes to actual execution, version records and source correspondence
실습 6종 · 풀이 포함 연습문제 60개6 labs · 60 exercises with solutions
기초Foundations
1. 어제의 답을 오늘 다시 만들 수 있을까1. Can today reproduce yesterday’s answer?
어제 평균을 구했는데 오늘은 파일을 찾지 못합니다. 다른 폴더에서 코드를 실행하니 같은 이름의 다른 파일을 읽기도 합니다. 계산 공식이 맞아도 입력·실행 순서·저장 위치를 설명하지 못하면 답을 재현하기 어렵습니다. 이 장은 숫자를 더 복잡하게 만드는 대신, 계산이 어디에서 무엇을 읽어 어떤 기록을 남기는지 따라갑니다.
먼저 가정 자료 2,4,6을 담은 작은 파일로 시작합니다. 그 다음 실제 16국가 파일, Card 사람 3,613행, NJ/PA 점포 410행으로 같은 원칙을 확인합니다. 실제 자료를 새로 관측하거나 정책 효과를 추정하는 실험은 아닙니다. 원자료의 키·결측·단위는 그대로 보존합니다.
한 언어를 먼저 선택해도 됩니다. Python/R 실행 파일은 내려받아 새 프로세스에서 실행할 수 있습니다. 브라우저 여섯 실습은 이미 실제로 실행해 보관한 유한 기록을 선택하거나 그 기록의 관계를 보여 줍니다. 현재 브라우저가 Python·R·Git·Jupyter를 실행하는 것은 아닙니다.
Yesterday you computed a mean; today the program cannot find its input. Launching from another folder can even read a different file with the same name. Correct arithmetic is insufficient when input, order and location cannot be explained. This chapter follows where a computation reads its input and what evidence it leaves.
Begin with a toy file containing 2, 4, 6. Then apply the same principles to retained files for 16 countries, 3,613 Card person records and 410 NJ/PA store records. These are not new observations or policy-effect experiments. Preserve source keys, missing fields and units.
Choose one language initially. Downloadable Python/R files can run in fresh processes. The six browser labs select finite archived actual runs or display relationships among their records. They do not run live Python, R, Git or Jupyter.
기초Foundations
2. 파일과 메모리의 객체를 나눈다2. Separate a file from an object in memory
파일은 저장 장치에 남긴 바이트의 모음입니다. 메모리의 rows는 지금 실행 중인 프로그램에서 이름에 연결한 객체입니다. 파일이 있어도 읽기 명령을 실행하지 않았다면 rows가 생기지 않습니다. 반대로 rows를 바꿔도 쓰기 명령이 없다면 원파일이 자동으로 바뀌지 않습니다.
종이에 적힌 표와 그 표를 읽어 칠판에 옮긴 값을 생각하세요. 칠판을 지워도 종이는 남고, 칠판에서 계산한 새 평균을 종이에 저절로 기록하지도 않습니다. 프로그램 종료로 메모리 객체가 사라질 수 있으므로 재현에 필요한 입력·코드·설명을 파일로 보관합니다.
A file is a collection of stored bytes. An in-memory rows is an object bound to a name in a running program. An existing file does not create rows before a read operation. Changing rows does not automatically rewrite its source file.
Think of a paper table and values copied from it onto a board. Erasing the board leaves the paper; a new mean on the board does not write itself back onto the paper. Preserve inputs, code and explanations because process memory can disappear when execution ends.
기초Foundations
3. 작은 프로젝트의 지도를 만든다3. Draw a small project map
프로젝트는 관련 파일을 함께 관리하는 작업 묶음입니다. 다음 예에서 analysis.py와 analysis.R은 같은 가정 입력을 읽는 두 언어의 코드이며 둘 다 실행할 필요는 없습니다. nested는 실행 출발점을 바꾸기 위한 빈 하위 폴더입니다.
파일명은 내용을 설명하는 단서이지 정확성의 증명은 아닙니다. final이라는 이름보다 입력 해시·변경 기록·실행 기록이 더 구체적입니다. 원자료, 작업 사본, 코드, 생성 결과를 구분해 두면 어떤 파일을 다시 만들어도 되는지 판단하기 쉽습니다.
A project groups related work. Here analysis.py and analysis.R read the same toy input in different languages; running both is optional. The empty nested folder changes the launch location for the path experiment.
A filename suggests content but does not prove correctness. Input hashes, changes and execution records are more specific than the word final. Distinguish source data, working copies, code and generated results so you can tell which files may safely be regenerated.
기초Foundations
4. 현재 작업 폴더는 어디인가4. Where is the current working directory?
현재 작업 폴더는 상대 경로를 해석할 때 사용하는 출발점입니다. 코드 파일이 놓인 폴더와 같을 수도 있지만 항상 같지는 않습니다. 프로그램을 프로젝트 폴더에서 시작했는지 nested에서 시작했는지가 같은 문자열 input/values.csv의 대상을 바꿀 수 있습니다.
from pathlib import Path
print(Path.cwd())
getwd()
이 두 명령은 현재 환경을 조회합니다. 실습의 project/nested는 실제 실행 당시의 출발점을 기록한 선택지입니다. 브라우저가 지금 사용자의 디스크를 조회했다는 뜻이 아닙니다. 경로 오류가 나면 파일명을 바꾸기 전에 출발점부터 확인하세요.
The current working directory is a base for relative paths. It can equal the code file’s folder, but need not. Launching from the project folder versus nested can change the target of the identical text input/values.csv.
from pathlib import Path
print(Path.cwd())
getwd()
These commands inspect a running environment. The lab’s project/nested choices label actual archived launch locations; the browser is not inspecting your disk. Check the base directory before renaming an input that a program cannot find.
기초Foundations
5. 상대 경로와 절대 경로를 읽는다5. Read relative and absolute paths
input/values.csv는 출발점이 필요한 상대 경로입니다. 절대 경로는 운영체제가 정한 뿌리부터 위치를 지정합니다. Windows의 드라이브 경로나 다른 운영체제의 / 경로가 그 예입니다. 어떤 형식이 절대 경로인지는 실행 환경의 규칙으로 판단합니다.
내 컴퓨터의 긴 절대 경로를 코드에 박아 넣으면 다른 사람의 폴더 구조에서 실패할 수 있습니다. 그렇다고 모든 경로를 무조건 상대 경로로 바꾸면 해결되는 것도 아닙니다. 상대 경로의 기준을 프로젝트 폴더로 할지, 코드 파일의 폴더로 할지 먼저 선언해야 합니다. 공백·한글이 있는 경로는 명령 인자로 전달할 때 따옴표로 묶습니다.
input/values.csv is relative and needs a base. An absolute path locates a file from the platform’s root, such as a Windows drive path or a Unix root path. Interpret path forms under the actual platform’s rules.
Hard-coding a personal absolute path can fail on another machine. Replacing everything with relative text does not itself solve the problem: declare whether the base is the project directory or the script directory. Quote command arguments containing spaces or Korean characters.
기초Foundations
6. 코드 파일을 기준으로 입력을 찾는다6. Anchor input to a script file
이 장의 Python 경로 예제는 Path(__file__).resolve().parent로 실행 파일이 있는 폴더를 구합니다. 파일로 실행한 일반 스크립트의 __file__을 이용합니다. 노트북이나 대화형 창에 같은 이름이 언제나 존재한다고 가정하지 않습니다.
Rscript 예제는 commandArgs(FALSE)에서 --file= 인자를 읽어 코드 위치를 구합니다. 이 역시 선언한 Rscript 실행 방법의 계약입니다. 단순 문자열에서 ..를 지우는 일과 실제 파일 시스템의 링크를 고려해 경로를 해석하는 일은 다를 수 있습니다.
base = Path(__file__).resolve().parent
path = base / "input" / "values.csv"
코드 기준 경로가 모든 프로그램의 정답은 아닙니다. 사용자가 --input으로 파일을 명시하는 방식도 가능합니다. 핵심은 어떤 기준을 쓰는지 설명하고 다른 출발점에서도 검사하는 것입니다.
The Python example uses Path(__file__).resolve().parent to locate a script’s folder. This relies on __file__ in an ordinary file execution, not on an assumption that every interactive console or notebook defines it.
The Rscript example reads its --file= argument through commandArgs(FALSE). That is a contract for this launch method. Removing .. from text is also different from resolving a real filesystem path where symbolic links can matter.
base = Path(__file__).resolve().parent
path = base / "input" / "values.csv"
A script-relative path is not mandatory for every program. An explicit --input argument is another design. Declare the base and test a different launch directory.
기초Foundations
7. 실제 경로 코드와 오류를 읽는다7. Read actual path code and failure
다음은 실제 실행한 Python 코드입니다. script 선택은 코드 위치를 기준으로 삼고 cwd 선택은 실행 출발점을 씁니다. 파일을 찾지 못하면 오류 내용을 출력하고 비영 종료 상태로 멈춥니다. 파일이 없다는 상황에서 빈 자료의 평균을 성공 결과처럼 내지 않습니다.
import csv, json, sys
from pathlib import Path
anchor = sys.argv[1]
base = Path(__file__).resolve().parent if anchor == "script" else Path.cwd()
path = base / "input" / "values.csv"
if not path.is_file():
print(json.dumps({"error": "input/values.csv is absent under the chosen base"}))
raise SystemExit(2)
with path.open(encoding="utf-8", newline="") as handle:
values = [int(row["value"]) for row in csv.DictReader(handle)]
print(json.dumps({"n": len(values), "sum": sum(values), "mean": sum(values)/len(values)}))
{"n": 3, "sum": 12, "mean": 4.0}
프로젝트 출발의 두 기준은 모두 n=3, 합=12, 평균=4를 냈습니다. nested 출발에서는 script 기준만 성공했고 cwd 기준은 입력 부재로 멈췄습니다. 이 Windows R 실행에는 UTF-8 문자 설정도 코드에 명시했습니다. 경고·실제 종료 상태는 원기록에 보존합니다.
This Python program was actually executed. The script option anchors to the code file; cwd uses the launch directory. A missing input prints an error and exits unsuccessfully rather than reporting an empty-data mean as success.
import csv, json, sys
from pathlib import Path
anchor = sys.argv[1]
base = Path(__file__).resolve().parent if anchor == "script" else Path.cwd()
path = base / "input" / "values.csv"
if not path.is_file():
print(json.dumps({"error": "input/values.csv is absent under the chosen base"}))
raise SystemExit(2)
with path.open(encoding="utf-8", newline="") as handle:
values = [int(row["value"]) for row in csv.DictReader(handle)]
print(json.dumps({"n": len(values), "sum": sum(values), "mean": sum(values)/len(values)}))
{"n": 3, "sum": 12, "mean": 4.0}
Both bases succeeded from the project directory, yielding n=3, sum=12 and mean=4. From nested, only the script base succeeded. The Windows R counterpart explicitly sets a UTF-8 character locale. Its warnings and actual exit status remain in the archived record.
기초Foundations
8. 실습 A: 출발점과 기준점을 바꾼다8. Lab A: change launch location and base
먼저 입력이 어디에 있어야 하는지 예상하세요. project/cwd라면 path-demo/input이고 nested/cwd라면 path-demo/nested/input입니다. 코드 위치 기준은 출발점이 달라도 path-demo/input을 가리킵니다. 성공 여부와 stdout, stderr, 코드 해시를 각각 확인합니다.
이 실습은 준비된 여덟 프로세스 기록을 선택합니다. 사용자의 새 파일이나 새 코드를 실행하지 않습니다. 실제 실행은 내려받은 path-demo 폴더를 보존한 뒤 명령 창에서 수행하세요.
Predict the requested input first. Project/cwd refers to path-demo/input; nested/cwd refers to path-demo/nested/input. The script base stays at path-demo/input across launch locations. Inspect success, stdout, stderr and code hash separately.
This lab selects eight archived process records. It does not execute your new files or code. To execute the program, preserve the downloaded path-demo folder and use a command window.
기초Foundations
9. 바이트와 해석한 표는 서로 다른 층이다9. Bytes and an interpreted table are different layers
파일의 바이트는 저장된 수치 단위이고, CSV 표는 그 바이트를 문자·구분자·열 이름 규칙으로 해석한 결과입니다. 같은 화면의 표라도 줄 끝, 인코딩, 따옴표 방식이 달라 파일 바이트는 다를 수 있습니다. 반대로 같은 바이트를 잘못된 구분자로 읽으면 잘못된 표를 만들 수 있습니다.
파일 크기만 같다고 내용도 같은 것은 아닙니다. 가정 파일에서 값 4를 5로 바꾸면 글자 수는 그대로여도 값은 달라집니다. 기록에서 바이트 비교와 분석용 키·값 비교를 별도 항목으로 두는 이유입니다.
Bytes are stored units; a CSV table results from interpreting them under encoding, delimiter and header rules. Tables can look identical while line endings, encoding or quoting differ. Conversely, identical bytes can be misread under an unsuitable delimiter.
Equal file size does not imply equal content. Replacing toy value 4 by 5 preserves character count while changing a value. Keep byte comparison separate from a declared comparison of analytical keys and values.
기초Foundations
10. LF와 CRLF는 왜 파일 크기를 바꿀까10. Why do LF and CRLF change file size?
줄 끝을 나타내는 LF는 이 비교에서 한 바이트, CRLF는 두 바이트입니다. 실제 16국 CSV는 머리글을 포함한 17개 줄 끝을 갖습니다. LF 사본은 1,163바이트, CRLF 사본은 1,180바이트이므로 차이는 17바이트입니다. 표의 16개 국가 수치가 17개 늘어난 것은 아닙니다.
이 계산은 이번 보관 파일의 실제 바이트에 대한 설명입니다. 모든 파일이 마지막 줄 끝을 갖는다거나 모든 문자 한 개가 한 바이트라고 일반화하지 마세요. UTF-8 한글은 여러 바이트를 사용할 수 있습니다. CSV를 읽는 프로그램이 두 줄 끝을 어떻게 처리하는지도 확인해야 합니다.
In this comparison LF uses one byte per line ending and CRLF two. The retained 16-country CSV contains 17 line endings including its header. The LF copy has 1,163 bytes and CRLF 1,180, a difference of seventeen bytes—not seventeen additional country values.
This arithmetic describes the retained files. It does not imply every file ends in a newline or every character occupies one byte. Korean UTF-8 characters can use multiple bytes. Also verify how the reader handles both line-ending forms.
기초Foundations
11. SHA-256은 무엇을 비교하는가11. What does SHA-256 compare?
해시 함수는 임의 길이 입력 바이트에서 고정 길이 값을 계산합니다. SHA-256의 보통 16진 표시에는 64개 문자가 있습니다. 입력을 같은 방식으로 읽고 해시가 같으면 바이트 동일성의 강한 실무 근거가 됩니다. 수학적으로 서로 다른 모든 입력에 서로 다른 해시가 배정되는 것은 아닙니다.
from hashlib import sha256
from pathlib import Path
print(sha256(Path("input/values.csv").read_bytes()).hexdigest())
해시만 보고 원자료 측정이 정확하다거나 게시자가 진짜라고 결론내릴 수 없습니다. 신뢰할 수 있는 비교 기준을 어디서 받았는지, 코드가 실제 그 파일을 읽었는지, 분석 단위가 맞는지도 따로 확인합니다. 한 글자 차이를 찾는 실무 도구를 과학적 결론의 인증서로 바꾸지 않습니다.
A hash maps input bytes to a fixed-length value. SHA-256 normally appears as 64 hexadecimal characters. Matching hashes under the same byte-reading procedure provide strong practical evidence of byte identity, although the function is not mathematically one-to-one over all possible inputs.
from hashlib import sha256
from pathlib import Path
print(sha256(Path("input/values.csv").read_bytes()).hexdigest())
A hash alone does not establish measurement accuracy or publisher authenticity. Ask where the trusted comparison value came from, whether the program read that file and whether observation units are suitable. Content checking is not certification of a scientific conclusion.
기초Foundations
12. 비교 규칙을 먼저 선언한다12. Declare a comparison rule first
두 표가 같은지 묻기 전에 무엇을 같다고 할지 정합니다. 이 장의 지정 비교는 원행 키를 보존한 전체 기록을 읽고, 명시한 수치 정규화를 적용한 다음 원행 키로 정렬해 비교합니다. 행 순서와 줄 끝은 무시하지만 값·결측 필드·키의 차이는 보존합니다.
이 규칙을 바꾸면 답도 바뀔 수 있습니다. 시계열 순서 자체가 분석 입력이면 순서를 무시하면 안 됩니다. 이름의 대소문자, 날짜 해석, 수치 반올림을 마음대로 없애는 규칙은 실제 차이를 숨길 수 있습니다. ‘같음’의 범위와 제외한 정보부터 기록하세요.
Before asking whether tables are the same, specify what sameness means. This chapter’s declared rule retains whole records and source keys, applies stated numerical normalization, then compares records sorted by source key. It disregards order and line endings while retaining value, missing-field and key differences.
Another rule can produce another answer. Do not discard order when sequence itself is analytical input. Unstated case folding, date interpretation or rounding can hide important differences. Record both the comparison scope and the information it discards.
기초Foundations
13. 행 전체를 정렬해야 짝이 유지된다13. Sort whole records to preserve pairs
점포 한 행에 원행 키, 전 FTE, 후 FTE가 함께 있습니다. 전체 행을 같은 순열로 옮기면 세 필드의 대응은 유지됩니다. 후 FTE만 따로 정렬하고 전 FTE를 원순서에 남기면 서로 다른 점포가 한 쌍으로 붙을 수 있습니다.
작은 가정 예에서 전 값 (1,10), 후 값 (3,11)은 변화 (2,1)입니다. 후 값만 뒤집으면 변화 (10,−7)이고 평균은 둘 다 1.5입니다. 합과 평균이 같아도 개별 변화·분산·관측 대응이 같다고 볼 수 없습니다. 실제 384개 완전짝에서도 이 문제가 나타납니다.
A store row contains its source key and before/after FTE together. Applying one permutation to whole rows preserves those correspondences. Sorting only after FTE while leaving before FTE in its original order can pair different stores.
For toy before values (1,10) and after values (3,11), changes are (2,1). Reversing after alone gives (10,−7); both means are 1.5. An unchanged sum or mean does not establish identical changes, variances or observed pairing. The actual 384 complete pairs illustrate this problem too.
기초Foundations
14. 실습 B: 바이트와 지정 비교를 나눈다14. Lab B: separate byte and declared-record identity
국가 줄 끝 사본, 점포 전체 행 정렬 사본, 가정 값 하나를 바꾼 사본을 비교합니다. 파일 크기·SHA-256·지정 규칙 아래 기록 동일성을 서로 다른 질문으로 읽으세요. 실습이 표시하는 해시는 실제 파일 바이트에서 계산해 보관한 값입니다.
첫 두 비교는 바이트가 달라도 지정 기록 비교에서는 같습니다. 가정 값 변경은 두 비교 모두 다릅니다. 이 관찰이 모든 파일 형식과 모든 정규화 규칙을 검증한 것은 아닙니다.
Compare country newline copies, store whole-row sorting and a chosen toy-value edit. Read file size, SHA-256 and declared-record equality as different questions. Displayed hashes were computed from actual retained bytes.
The first two pairs differ in bytes but agree under the specified record rule. The toy edit differs under both comparisons. These observations do not validate every file format or every possible normalization rule.
기초Foundations
15. 원자료와 다시 만들 수 있는 결과를 구분한다15. Separate sources from regenerable results
원자료 보관본을 수정하지 않고 작업 사본에서 줄 끝·정렬·분석 형식을 바꿉니다. 생성 결과에는 어떤 입력과 코드에서 나왔는지 연결을 둡니다. ‘작업 파일’이라는 이름만으로 삭제해도 된다는 뜻은 아닙니다. 재생성 코드와 입력이 실제 남아 있는지 먼저 확인합니다.
표 전체를 보존한 사본과 가용값만 추린 분석표도 다릅니다. 사람 자료 3,613행을 보관한 파일과 3,010개 로그만 모은 벡터는 분모와 결측 정보를 다르게 갖습니다. 다음 장의 읽기·정제에서도 이 구별을 유지합니다.
Retain source archives unchanged and transform working copies. Link each generated result to its input and code. Calling a file temporary does not prove it is safe to delete: first verify that the required inputs and generation procedure remain available.
A whole-record copy also differs from an available-only analytical table. The 3,613-row person file and a vector of 3,010 available logs carry different missingness and denominator information. Preserve that distinction during later import and cleaning.
기초Foundations
16. 재현·반복·정확성을 따로 묻는다16. Ask separately about reproduction and correctness
같은 입력과 코드로 같은 답을 다시 얻는 일은 중요한 점검입니다. 하지만 잘못된 짝짓기도 같은 방식으로 반복하면 같은 틀린 결과를 냅니다. 재현 가능성은 원측정 정확성·인과 식별·다른 모집단 일반화를 대신하지 않습니다.
검사 순서를 정해 보세요. 먼저 어떤 파일인지, 다음 어떤 원행·열을 읽었는지, 그 다음 단위·분모·키 대응이 맞는지, 마지막으로 산술과 해석이 맞는지 확인합니다. 해시 하나나 평균 하나에 모든 증거를 맡기지 않습니다.
Obtaining the same answer again from retained input and code is valuable. Yet repeating an invalid pairing can reproduce the same wrong answer. Reproducibility does not replace measurement accuracy, causal identification or generalization to another population.
Check file identity, selected source rows/fields, units, denominators and key correspondence before arithmetic and interpretation. Do not ask one hash or one matching mean to carry all the evidence.
기초Foundations
17. 변경 전후를 이름만으로 관리하지 않는다17. Track changes beyond filenames
analysis_final.py, analysis_final2.py, analysis_really_final.py가 쌓이면 어느 입력에 어느 코드가 대응하는지 혼동하기 쉽습니다. 버전 기록은 특정 시점의 내용과 변경 이유를 연결하는 방법입니다. 파일 이름, 저장된 내용, 실행 결과를 구별해야 합니다.
Git은 코드와 작은 텍스트 파일의 변경을 기록하는 도구입니다. 이 장에서는 원격 서비스나 협업 명령보다 한 파일의 작업 내용·준비 영역·커밋을 먼저 배웁니다. Git을 쓴다는 사실만으로 연구가 정확하거나 원자료 사용 권한이 생기는 것은 아닙니다.
Files named analysis_final.py, analysis_final2.py and analysis_really_final.py can obscure which code belongs with which input. Version records connect a particular content state to an explanation of change. Filename, content and execution result remain separate.
Git records changes in code and other files. Begin with one file’s working content, staging area and commit before remote collaboration. Using Git does not itself validate research or grant data permissions.
기초Foundations
18. 작업 파일·준비 영역·HEAD의 세 칸18. Three places: working file, index and HEAD
작업 파일은 편집기가 현재 디스크에 저장한 내용입니다. 준비 영역(index)은 다음 커밋에 넣도록 선택해 둔 내용입니다. HEAD는 보통 현재 커밋을 가리키며 여기서는 그 커밋에 들어 있는 analysis.py를 읽습니다. 아직 커밋이 없으면 HEAD의 해당 파일도 없습니다.
이 세 칸은 복사본 세 개를 수동으로 관리하라는 뜻이 아니라 Git의 서로 다른 상태를 읽는 모형입니다. 준비 영역이 없다는 상태와 내용이 길이 0인 빈 파일은 다릅니다. 첫 커밋 전의 부재를 빈 코드로 표시하면 실제 상태를 잘못 설명합니다.
The working file is content currently saved by the editor. The index contains the version selected for the next commit. HEAD normally refers to the current commit; here we inspect analysis.py inside it. Before the first commit, that committed file is absent.
This is a model of Git states, not advice to maintain three manual copies. An absent indexed file differs from a present empty file. Showing absence as empty code would misdescribe the first-commit boundary.
기초Foundations
19. 쓰기와 add는 서로 다른 동작이다19. Writing and adding are different operations
첫 가정 코드 v1은 print(2 + 2)입니다. 파일을 저장하면 작업 파일은 생기지만 Git은 아직 추적하지 않습니다. git add analysis.py는 현재 내용을 준비 영역에 넣습니다. 코드가 Python에서 실행되었다는 뜻은 아닙니다.
git status --porcelain=v1
git add analysis.py
git status --porcelain=v1
이 장의 상태 출력은 기계가 읽기 쉬운 porcelain 형식입니다. 첫 상태 열은 준비 영역, 다음 열은 작업 파일의 변경을 요약합니다. 처음 보는 문자를 외우기보다 실습의 세 실제 내용을 나란히 비교하세요.
Toy version v 1 contains print(2 + 2). Saving creates a working file, initially untracked by Git. git add analysis.py stages its current content. It does not execute Python.
git status --porcelain=v1
git add analysis.py
git status --porcelain=v1
The archived status uses Git’s porcelain format. Its first status column concerns the index and the next the working file. Compare the three actual contents rather than merely memorizing unfamiliar status letters.
기초Foundations
20. add 다음에 고치면 무엇이 커밋될까20. What is committed after editing a staged file?
v1을 add한 뒤 작업 파일을 v2인 print(2 + 3)으로 고칩니다. 준비 영역은 자동으로 v2가 되지 않아 여전히 v1입니다. 바로 커밋하면 v1이 기록됩니다. v2를 넣으려면 다시 add해야 합니다.
실제 교육용 Git 기록의 3단계는 작업 v2·준비 v1·HEAD 부재이고, 4단계에서 첫 커밋을 만들면 작업 v2·준비 v1·HEAD v1입니다. 편집기에서 최신 코드가 보인다는 사실과 그 코드가 커밋에 들어갔다는 사실은 다릅니다.
Stage v 1, then edit the working file to v 2, print(2 + 3). The index remains v 1. Committing immediately records v 1; stage again to include v 2.
Archived teaching stage 3 has working v 2, indexed v 1 and no HEAD file. Stage 4 commits v 1, leaving working v 2, indexed v 1 and HEAD v 1. Seeing new code in an editor does not establish that it entered a commit.
기초Foundations
21. 커밋은 실행 결과가 아닌 선택 내용의 기록이다21. A commit records selected content, not an execution
첫 커밋 뒤 v2를 add하고 두 번째 커밋을 만들면 세 내용이 v2로 일치합니다. 커밋 메시지는 왜 바꿨는지 짧게 설명합니다. 커밋 식별자는 특정 기록을 가리키는 단서이며, 분석이 실제 실행되었다는 증명은 아닙니다.
Git 상태가 깨끗해도 필요한 외부 입력을 잃었거나, 추적하지 않는 결과 파일이 있을 수 있습니다. 코드 커밋·입력 해시·실행 명령·버전·출력 검사를 묶어야 실행을 재현하기 쉬워집니다. 원격에 올리는 일도 이 장의 실행 기록에 포함되지 않습니다.
After the first commit, stage v 2 and create the second commit; all three contents then agree at v 2. Explain the reason for a change in its message. A commit identifier locates a record; it does not prove the analysis executed.
A clean Git state can coexist with missing external inputs or untracked outputs. Pair a code commit with input hashes, command, runtime version and output checks. No remote publication is part of this teaching run.
기초Foundations
22. 실습 C: 실제 Git 일곱 상태를 읽는다22. Lab C: inspect seven actual Git states
0부터 6까지 차례로 이동하며 작업·준비·HEAD를 비교하세요. 세 칸에 처음 차이가 나는 순간, add 뒤 편집한 순간, 첫 커밋의 내용을 예측합니다. 파일 부재는 대시로 표시하며 빈 파일과 구별합니다.
기록은 이 교재를 위해 새로 만든 격리 로컬 저장소에서 실제 Git 명령을 실행해 만들었습니다. 기존 연구 저장소·전역 설정·원격 서비스는 바꾸지 않았습니다. 교육용 이름과 커밋을 실제 연구자의 과거 작업 이력으로 해석하지 않습니다.
Move through stages zero to six, comparing working, index and HEAD. Predict their first difference, the edit after add and the first commit’s content. Absence appears separately from an empty file.
Real Git commands created this record in a new isolated local teaching repository. Existing research repositories, global settings and remotes were unchanged. The teaching identity and commits are not a researcher’s historical workflow.
기초Foundations
23. 버전 기록에 무엇을 넣고 무엇을 연결할까23. What belongs in version history or its manifest?
코드·설명서·작은 설정 파일은 함께 기록하기 좋습니다. 큰 원자료·비공개 자료·비밀 키는 파일 특성과 권한을 먼저 판단합니다. 여기서는 원자료를 Git에 넣는 대신 보관 파일의 위치·해시·관측 단위를 실행 설명서에 연결합니다. 모든 프로젝트가 같은 저장 정책을 가질 필요는 없습니다.
버전 기록이 있다고 별도 백업이 자동으로 생기지는 않습니다. 로컬 장치 하나를 잃으면 그 안의 저장소도 잃을 수 있습니다. 되돌리기·삭제 같은 명령을 외우기 전에 현재 파일과 기록을 복사해 연습할 범위를 확인하세요. 이 장의 브라우저는 저장소를 수정하지 않습니다.
Code, documentation and small configuration files often fit version history. Judge large inputs, restricted records and secrets by their properties and permissions. Here, source-file location, hash and observation unit are linked in a manifest rather than placing every input in Git.
Version history is not automatically a separate backup: losing the only local device can lose its repository. Before practicing destructive operations, establish a safe practice copy and its scope. This chapter’s browser never changes a repository.
기초Foundations
24. 실행 설명서는 입력과 결과를 잇는다24. A run manifest connects inputs and results
다른 사람이 재현하려면 코드 파일과 입력 파일만 받을 때보다 실행 기준까지 알 때 유리합니다. 실행 설명서에 입력 경로·해시, 코드 경로·해시, 실행 버전, 출발 폴더, 명령 인자, 종료 상태, 표준 출력과 오류 출력을 남깁니다. 필요하면 생성 결과의 해시도 추가합니다.
로그는 언제 어떤 프로그램이 무엇을 기록했는지에 대한 증거입니다. 모든 행동이 빠짐없이 남았다고 가정하지 않습니다. 이번 카탈로그는 선언한 고정 실행만 담으며 사용자 컴퓨터의 전체 작업을 추적하지 않습니다.
A colleague needs more than code and input names. Record input path/hash, code path/hash, runtime, launch directory, command arguments, exit status, stdout and stderr. Add output-file hashes when relevant.
A log is evidence of what a particular recorder captured, not an assumption that every action was captured. This catalog covers declared fixed runs, not the user’s complete computer activity.
기초Foundations
25. 노트북은 셀과 저장 출력이 있는 파일이다25. A notebook stores cells and possibly outputs
노트북은 설명·코드·출력을 셀로 묶을 수 있는 문서입니다. .ipynb 형식은 JSON 구조에 셀 종류, 소스, 메타데이터, 버전 등을 저장합니다. 코드 셀은 execution_count와 outputs 필드도 가집니다. 이 장의 소스 전용 노트북은 실행 횟수 null, 저장 출력 빈 배열입니다. 4.5 형식의 각 셀에는 고유한 id도 필요합니다. 새 예시는 data03-cell-1부터 data03-cell-3까지 보존합니다. JSON으로 읽힌다는 사실만으로 형식의 모든 요구를 검증했다고 말하지 않습니다.
형식에 맞는 파일을 만들었다는 사실과 Jupyter 커널로 실행했다는 사실은 다릅니다. 이 장의 소스 노트북은 Jupyter로 실행하지 않았습니다. 대신 같은 고정 코드 셀을 실제 Python/R의 새 일반 프로세스에서 순서별로 실행한 기록을 보관합니다.
A notebook can combine explanation, code and output in cells. The .ipynb format stores JSON fields for cell type, source, metadata and format version. Code cells also have execution_count and outputs. The source-only notebook here has null execution counts and empty output arrays. Format 4.5 also requires a unique cell id; the new example retains data03-cell-1 through data03-cell-3. Merely parsing JSON does not validate every format requirement.
A structurally valid file is different from a notebook executed by a Jupyter kernel. This source notebook was not kernel-executed. The fixed cells were instead run in fresh ordinary Python/R processes in declared orders.
기초Foundations
26. 보이는 셀과 현재 메모리는 다를 수 있다26. Visible cells can differ from current memory
셀1이 rows를 2,4,6으로 만들고 셀2가 평균 answer를 계산하며 셀3이 rows를 10,20으로 바꾼다고 합시다. 화면의 셀 순서가 1,2,3이어도 사람이 클릭한 실행 순서는 1,3,2일 수 있습니다. 저장된 출력도 과거 실행에서 남았을 수 있습니다.
노트북을 읽을 때는 소스·출력·현재 세션 상태·실행 순서를 나누어 봅니다. 실행 횟수 표시는 단서이지만 입력 파일이 같았는지나 숨은 상태가 없었는지까지 인증하지 않습니다.
Let cell 1 create rows 2,4,6; cell 2 compute answer; cell 3 replace rows by 10,20. Although cells are displayed as 1,2,3, a person might execute 1,3,2. Saved outputs may also come from an earlier state.
Separate source, saved output, current session state and execution order. Execution counts provide clues, but do not certify matching inputs or absence of hidden state.
기초Foundations
27. 123과 132의 마지막 답은 왜 다른가27. Why do 123 and 132 finish differently?
123에서는 answer=4를 저장한 다음 rows만 10,20으로 바꿉니다. answer는 자동으로 다시 계산되지 않아 마지막 상태는 rows=(10,20), answer=4입니다. 132에서는 입력을 바꾼 뒤 계산하므로 answer=15입니다.
두 기록 모두 코드 오류 없이 끝나지만 하나는 현재 rows의 평균을 담지 않습니다. 오류 없음은 계산 의존성이 최신 상태라는 뜻이 아닙니다. 입력을 변경한 뒤 어떤 결과를 다시 계산해야 하는지 명시하세요.
Order 123 stores answer=4 before replacing rows by 10,20. Rebinding rows does not recalculate answer; the final state contains rows=(10,20), answer=4. Order 132 computes after the replacement, yielding answer=15.
Both runs end without a code error, but one answer no longer describes current rows. Absence of an error does not establish current dependencies. State which results must be recomputed after an input changes.
기초Foundations
28. 오류를 잡고 계속하는 기록기의 규칙28. The recorder’s rule for continuing after an error
셀2부터 실행하면 아직 rows가 없어 이름 오류가 납니다. 이 장의 기록기는 셀마다 오류를 잡고 다음 선택 셀을 실행하도록 작성했습니다. 따라서 213은 첫 오류 뒤 셀1과 셀3을 실행하지만 answer는 만들어지지 않습니다.
일반 스크립트가 처리하지 않은 오류 뒤 항상 계속된다는 뜻은 아닙니다. 오류 포착·재시도·중단은 프로그램이 정한 제어 규칙입니다. 뒤 셀이 성공했다는 이유로 앞의 실패를 숨기지 않습니다. 원기록에는 오류 종류와 메시지가 남습니다.
Running cell 2 first fails because rows is absent. This recorder explicitly catches each cell error and continues to the next selected cell. Thus 213 records an initial failure, then runs cells 1 and 3 without creating answer.
Ordinary scripts do not necessarily continue after an unhandled error. Catching, retrying and stopping follow the program’s control policy. Later success does not erase an earlier failure; its type and message remain recorded.
기초Foundations
29. 실습 D: 같은 세 셀의 여섯 순서를 추적한다29. Lab D: trace six orders of the same three cells
언어와 실행 순서를 선택하고 0~3단계에서 이름이 생기거나 바뀌는 시점을 확인하세요. 0단계는 새 프로세스의 빈 상태이며 실패 상태가 아닙니다. 오류가 있는 순서는 어느 이름이 아직 없었는지 설명합니다.
추적은 실제 일반 Python/R 프로세스의 기록입니다. 선택할 때마다 새 커널을 실행하지 않습니다. 다운로드한 소스 전용 .ipynb의 null 횟수·빈 출력과 일반 프로세스 기록을 혼동하지 않습니다.
Select a language and execution order, then inspect steps zero to three. Step zero is an empty fresh state, not failure. For an error, identify the binding that did not yet exist.
These are actual ordinary Python/R process records, not new kernel runs on selection. Keep them distinct from the downloadable source-only .ipynb with null counts and no saved outputs.
기초Foundations
30. 새로 시작해 전체 실행하는 이유30. Why restart and run from the beginning?
앞선 세션의 이름이 남아 있으면 빠진 입력 읽기 줄을 알아채기 어렵습니다. 새 프로세스에서 필요한 입력 생성·함수 정의·계산을 순서대로 실행하면 그 의존성을 점검할 수 있습니다. 노트북에서도 새 커널과 전체 순서 실행은 숨은 상태를 줄이는 중요한 확인입니다.
그래도 모든 재현 문제가 사라지지는 않습니다. 외부 파일 변경·난수·네트워크 응답·패키지 버전·작업 폴더도 영향을 줄 수 있습니다. 새 시작은 이들 입력을 기록하는 일과 함께 사용합니다. 이 장은 Jupyter의 실제 재시작을 수행했다고 주장하지 않습니다.
Leftover bindings can conceal an omitted input-loading line. A fresh process executing input creation, definitions and calculations in order tests these dependencies. In a notebook, a fresh kernel followed by ordered execution is likewise a useful check against hidden state.
It does not eliminate every reproduction issue: files, randomness, network responses, package versions and working directories can matter. Combine a fresh start with recorded inputs. This chapter does not claim to have performed an actual Jupyter restart.
기초Foundations
31. 탐색 노트와 반복 스크립트를 연결한다31. Connect exploratory notes with a repeatable script
노트북은 그림 옆에 질문과 해석을 두기 좋고, 스크립트는 입력부터 끝까지 실행할 명령 순서를 드러내기 좋습니다. 어느 형식도 자동으로 재현 가능하지는 않습니다. 둘 다 입력·상태·의존성·환경을 명시해야 합니다.
탐색 중 얻은 요약을 반복 작업으로 옮길 때는 함수로 묶고 명시적 입력과 반환을 정합니다. 노트북에서만 존재하는 이름을 스크립트가 몰래 참조하지 않게 합니다. 그림만 저장하지 말고 그 그림을 만든 코드와 원자료 범위를 함께 보관합니다.
Notebooks suit questions and interpretation beside figures; scripts expose an ordered path from input to completion. Neither format is automatically reproducible. Both require declared inputs, state, dependencies and environment.
When moving an exploratory summary into repeated work, define functions with explicit inputs and returns. Avoid script dependencies on names existing only in a notebook. Preserve a figure’s code and source scope as well as its image.
기초Foundations
32. 다시 계산할 입력을 함수에 명시한다32. Make recomputation inputs explicit
평균 계산을 함수로 묶더라도 함수가 바깥의 rows를 몰래 읽으면 숨은 상태가 남습니다. 입력 values를 인자로 받아 계산한 값을 반환하도록 정의하면 호출하는 줄에서 어떤 자료를 썼는지 더 분명해집니다. 함수 정의가 곧 호출은 아니며 입력 변경도 과거 반환값을 갱신하지 않습니다.
이 작은 예의 두 호출은 각각 4와15를 반환하며 마지막 할당값은15입니다. 입력은 비어 있지 않은 유한 수치라는 계약을 둡니다. 앞 장의 빈 입력·결측 처리까지 필요하면 함수 계약을 넓히고 그 경우를 따로 검사합니다.
Wrapping a mean in a function does not remove hidden state if it silently reads an outer rows binding. Accept values as an argument and return the result so the call identifies its input. Defining a function is not calling it, and changing input does not update an earlier returned value.
The calls return four and fifteen, leaving answer fifteen. The small contract assumes nonempty finite numerical input. Extend the contract and test separately when empty inputs or missingness rules from the preceding chapter are required.
기초Foundations
33. 스크립트의 입력·출력 계약을 쓴다33. State a script’s input/output contract
여기서 만들 스크립트의 입력은 실제 사람 기록을 보존한 CSV입니다. 출력은 전체 행 수·가용 로그 수·미관측 수·가용 로그 평균을 담은 JSON 한 줄입니다. 파일은 명령 인자로 받고 원파일을 쓰거나 덮어쓰지 않습니다. 평균의 단위는 원자료에 저장된 로그 변수입니다.
계약에는 성공 조건과 실패 조건도 들어갑니다. 파일이 없거나 예상 행 수가 다르면 성공 평균을 출력하지 않습니다. 행 수 검사는 잘못된 파일을 빠르게 발견하는 한 방법이지 같은 행 수를 가진 모든 잘못된 파일을 잡는 증명은 아닙니다.
The script input is a CSV retaining actual person records. Its output is one JSON line containing total, available and missing counts plus the available log mean. It takes a command argument and never overwrites its input. The mean remains in the recorded log variable’s units.
A contract includes success and failure. An absent file or unexpected row count does not yield a successful mean. A row-count check can catch some wrong inputs; it cannot prove every file with the expected count is correct.
기초Foundations
34. 명령과 코드 파일을 구별해 실행한다34. Distinguish the command from the code file
내려받은 교재 출력 폴더를 현재 작업 폴더로 삼았을 때 다음 명령은 실제 스크립트와 입력을 명시합니다. --input 뒤는 파일 경로이고 --expect-total 뒤는 검사할 수입니다. 셸에서 인자를 해석하는 단계와 Python/R이 CSV를 읽는 단계를 나누어 생각하세요.
긴 명령은 화면에서 줄바꿈되어 보여도 하나의 명령입니다. 자신이 선택한 언어 한 줄만 실행해도 됩니다. 다른 출발 폴더에서는 입력·코드 경로를 그 기준에 맞게 지정하거나 절대 경로를 명시합니다.
From the downloaded chapter output directory, these commands explicitly identify script and input. --input is followed by a path; --expect-total by a count. Separate shell argument handling from the program’s CSV reading.
A long wrapped line still represents one command. Run only your chosen language if preferred. From another launch directory, adapt both paths to that base or supply absolute paths.
기초Foundations
35. 전체 입력을 읽는 실제 Python 코드를 따라간다35. Trace the Python code reading the full input
다음 코드는 실제 실행 파일과 같습니다. DictReader는 열 이름으로 값을 찾습니다. 빈 문자열과 NA는 이 보관 CSV의 미관측 규칙이며, 값이 있는 필드는 Fraction으로 읽습니다. 가용값이 하나도 없으면 평균을 null로 둘 수 있도록 분기를 둡니다.
import argparse, csv, json
from fractions import Fraction
from pathlib import Path
p = argparse.ArgumentParser()
p.add_argument("--input", required=True)
p.add_argument("--expect-total", type=int, default=3613)
args = p.parse_args()
path = Path(args.input)
if not path.is_file():
print(json.dumps({"error": "input file is absent"}))
raise SystemExit(2)
with path.open(encoding="utf-8-sig", newline="") as handle:
rows = list(csv.DictReader(handle))
if len(rows) != args.expect_total:
print(json.dumps({"error": "unexpected record count", "actual": len(rows), "expected": args.expect_total}))
raise SystemExit(3)
field = "actual_source_trimmed1976_log_hourly_wage_cents"
values = [Fraction(row[field]) for row in rows if row[field] not in ("", "NA")]
mean = sum(values, Fraction(0)) / len(values) if values else None
print(json.dumps({"nTotal": len(rows), "nValid": len(values), "nMissing": len(rows)-len(values), "mean": float(mean) if mean is not None else None, "meanExact": str(mean) if mean is not None else None}))
이 코드의 실제 입력에는 가용값이 3,010개여서 평균이 정의됩니다. 숫자 0은 미관측 표식에 포함하지 않습니다. 정확 분수 계산은 이 유한 CSV의 유한 십진 필드에 대한 산술이며, 원래 측정의 무한 정밀도를 주장하지 않습니다.
This is the actually executed source file. DictReader locates fields by header. Blank and NA implement the retained CSV’s missingness convention; available fields become Fraction values. An explicit branch permits a null mean when no values are available.
import argparse, csv, json
from fractions import Fraction
from pathlib import Path
p = argparse.ArgumentParser()
p.add_argument("--input", required=True)
p.add_argument("--expect-total", type=int, default=3613)
args = p.parse_args()
path = Path(args.input)
if not path.is_file():
print(json.dumps({"error": "input file is absent"}))
raise SystemExit(2)
with path.open(encoding="utf-8-sig", newline="") as handle:
rows = list(csv.DictReader(handle))
if len(rows) != args.expect_total:
print(json.dumps({"error": "unexpected record count", "actual": len(rows), "expected": args.expect_total}))
raise SystemExit(3)
field = "actual_source_trimmed1976_log_hourly_wage_cents"
values = [Fraction(row[field]) for row in rows if row[field] not in ("", "NA")]
mean = sum(values, Fraction(0)) / len(values) if values else None
print(json.dumps({"nTotal": len(rows), "nValid": len(values), "nMissing": len(rows)-len(values), "mean": float(mean) if mean is not None else None, "meanExact": str(mean) if mean is not None else None}))
The actual input has 3,010 available logs, so its mean is defined. Numeric zero is not a missing marker. Exact fractions describe arithmetic on the finite recorded decimal fields, not infinite precision in original measurements.
기초Foundations
36. R도 같은 분모를 쓰는지 확인한다36. Check that R uses the same denominator
R 코드는 read.csv의 미관측 표식을 지정하고 !is.na(values)로 가용값을 골라 평균을 계산합니다. Python의 Fraction 반환과 R의 부동소수점 표시는 내부 계산 방식이 다릅니다. 같은 입력 해시·3,613/3,010/603 분모와 합리적인 수치 차이를 함께 확인합니다.
if (.Platform$OS.type == "windows") invisible(Sys.setlocale("LC_CTYPE", "English_United States.utf8"))
args <- commandArgs(trailingOnly=TRUE)
arg <- function(name, default=NULL) {
index <- match(name, args)
if (is.na(index)) return(default)
if (index == length(args)) stop("missing argument value")
args[index+1]
}
path <- arg("--input")
expected <- as.integer(arg("--expect-total", "3613"))
if (is.null(path) || !file.exists(path)) {
cat('{"error":"input file is absent"}\n'); quit(status=2)
}
rows <- read.csv(path, na.strings=c("", "NA"), check.names=FALSE)
if (nrow(rows) != expected) {
cat(sprintf('{"error":"unexpected record count","actual":%d,"expected":%d}\n', nrow(rows), expected)); quit(status=3)
}
values <- rows$actual_source_trimmed1976_log_hourly_wage_cents
valid <- values[!is.na(values)]
mean_text <- if (length(valid)) sprintf("%.17g", mean(valid)) else "null"
cat(sprintf('{"nTotal":%d,"nValid":%d,"nMissing":%d,"mean":%s}\n', nrow(rows), length(valid), sum(is.na(values)), mean_text))
이 Windows 환경의 문자 설정은 한글 경로 처리를 위한 것입니다. 시작 경고가 있더라도 종료 상태·출력·검사를 따로 읽습니다. 경고가 있으면 무조건 실패라고 하거나, 숫자가 나왔으니 모든 경고를 무시해도 된다고 일반화하지 않습니다.
The R code declares CSV missing markers and selects available values with !is.na(values). Its floating display differs from Python’s Fraction arithmetic. Check the same input hash, the 3,613/3,010/603 counts and an appropriate numerical comparison.
if (.Platform$OS.type == "windows") invisible(Sys.setlocale("LC_CTYPE", "English_United States.utf8"))
args <- commandArgs(trailingOnly=TRUE)
arg <- function(name, default=NULL) {
index <- match(name, args)
if (is.na(index)) return(default)
if (index == length(args)) stop("missing argument value")
args[index+1]
}
path <- arg("--input")
expected <- as.integer(arg("--expect-total", "3613"))
if (is.null(path) || !file.exists(path)) {
cat('{"error":"input file is absent"}\n'); quit(status=2)
}
rows <- read.csv(path, na.strings=c("", "NA"), check.names=FALSE)
if (nrow(rows) != expected) {
cat(sprintf('{"error":"unexpected record count","actual":%d,"expected":%d}\n', nrow(rows), expected)); quit(status=3)
}
values <- rows$actual_source_trimmed1976_log_hourly_wage_cents
valid <- values[!is.na(values)]
mean_text <- if (length(valid)) sprintf("%.17g", mean(valid)) else "null"
cat(sprintf('{"nTotal":%d,"nValid":%d,"nMissing":%d,"mean":%s}\n', nrow(rows), length(valid), sum(is.na(values)), mean_text))
The Windows character-locale setting supports Korean paths. Read startup warnings, exit status, output and checks separately. Neither “any warning means failure” nor “a number means warnings can be ignored” is a sound general rule.
기초Foundations
37. 파일 부재와 검사 실패를 구별한다37. Separate absent input from a failed check
missing-input 실행은 존재하지 않는 경로를 요청합니다. wrong-count 실행은 실제 파일을 읽되 예상 수를 3,614로 주어 실제 3,613과 충돌합니다. 전자는 파일 조회 실패이고 후자는 명시한 입력 검사 실패입니다. 둘 다 평균 성공 결과로 처리하지 않습니다.
기록의 requestedInputFile은 실제 요청 경로입니다. inputFile과 inputSha256은 보관 실제 참조 CSV의 식별값입니다. 없는 파일에 해시가 있다고 오해하지 않도록 두 역할을 나눠 표시합니다. 오류 메시지는 원인 조사에 쓰며 원자료를 임의로 고치는 지시가 아닙니다.
The missing-input run requests a nonexistent path. The wrong-count run reads the actual file but expects 3,614 instead of its 3,613 rows. One is failed file lookup; the other a failed declared check. Neither is presented as a successful mean.
requestedInputFile identifies the requested path; inputFile and inputSha256 identify the retained actual reference CSV. Display these roles separately rather than implying a hash exists for an absent file. An error helps investigate a cause; it is not an instruction to alter source data.
기초Foundations
38. 실습 E: 성공·경로 오류·검사 실패를 읽는다38. Lab E: inspect success, missing input and a failed check
언어와 실행 시나리오를 선택해 코드·요청 경로·참조 입력 해시·실제 stdout/stderr·종료 상태를 확인합니다. 실패 기록에서 평균이 없으면 0으로 채우지 않습니다. 평균을 낼 조건이 충족되지 않았다는 뜻입니다.
이 실습은 보관된 여섯 실행을 선택합니다. 실제 임의 코드를 실행하는 편집기가 아닙니다. 코드를 바꿨다면 내려받은 작업 사본에서 새 프로세스로 실행하고, 새 코드 해시와 새 기록을 남기세요.
Select language and scenario. Inspect source, requested path, reference-input hash, stdout/stderr and exit status. A missing mean in a failed run is not replaced by zero: its computation conditions were not met.
The lab selects six archived runs, not arbitrary edited code. After changing a downloaded working copy, execute it in a fresh process and retain a new code hash and run record.
기초Foundations
39. 환경과 입력의 범위를 기록한다39. Record the environment and input scope
이번 보관 실행은 Python 3.12.14, R 4.5.1과 실제 Git 버전 기록을 가집니다. 최신이라는 뜻은 아닙니다. 이 예제는 기본 라이브러리를 사용하지만, 패키지를 추가하는 분석에서는 패키지 버전과 설치 방법도 필요할 수 있습니다.
운영체제·문자 설정·출발 폴더·외부 파일·난수 상태처럼 결과에 영향을 줄 조건을 기록합니다. 비밀 인증 정보 자체를 로그에 남기지 않습니다. 작은 기록의 목표는 모든 컴퓨터 상태를 복제했다는 선언이 아니라, 이 실행에 필요한 의존성을 구체적으로 드러내는 것입니다.
The archived runs record Python 3.12.14, R 4.5.1 and the actual Git version. These are not claims of newest releases. The examples use standard facilities; analyses adding packages may also need package versions and installation instructions.
Record relevant operating-system, locale, launch-directory, external-input and random-state conditions. Do not log secret credentials. A small manifest exposes the dependencies of a declared execution rather than claiming to replicate every machine state.
기초Foundations
40. 작은 검사는 어떤 오류를 잡는가40. What can a small check detect?
가정 파일 2,4,6은 손으로 합 12·분모 3·평균 4를 확인할 수 있습니다. 실제 사람 파일에서는 전체 행 수, 가용 수, 미관측 수의 합, 입력 해시, 정확 분수 평균을 따로 검사합니다. 각 검사가 다른 오류를 잡습니다.
검사 통과를 모든 가능한 입력의 정확성 증명이라고 부르지 않습니다. 예를 들어 행 수 검사만으로 열이 잘못 선택된 문제를 발견하지 못할 수 있습니다. 계산 단위·원행 대응·과학적 해석은 별도 읽기와 반례가 필요합니다.
For toy values 2,4,6, verify sum twelve, denominator three and mean four by hand. For the actual person file, separately check total, available and missing counts, input hash and exact-fraction mean. These checks detect different problems.
Passing them is not a proof over every possible input. A row-count check alone may miss a wrongly selected column. Units, source correspondence and scientific interpretation need separate reading and counterexamples.
기초Foundations
41. 실제 16국 파일에서 달라진 것은 무엇인가41. What changed in the actual 16-country files?
두 사본의 값은 2024년 16국가의 1인당 실질 GDP입니다. 원행과 국가·연도·지표를 보존했습니다. 줄 끝만 바꾼 비교에서 1,163과 1,180이라는 바이트 수를 GDP나 인구로 읽지 않습니다. 공표 수치를 새로 관측한 자료도 아닙니다.
LF/CRLF 해시는 다르지만 이 장의 지정 키·값 정규화 결과는 같습니다. 같은 데이터 의미라는 표현은 이 선언 범위에 한정합니다. 원 World Bank 파일의 출처와 보관 해시는 따로 유지합니다.
The two working copies retain 2024 real GDP per person for 16 countries, with source row, country, year and indicator. The 1,163 versus 1,180 byte counts are not GDP or population. These are retained published values, not newly collected measurements.
LF/CRLF byte hashes differ while the declared key/value normalization agrees. Any claim of equivalent analytical content is limited to that rule. Source provenance and the retained World Bank archive hash remain separate.
기초Foundations
42. 실제 로그 3,010개의 분모를 지킨다42. Preserve the denominator of 3,010 actual logs
Card 원자료 사람 기록은 3,613행이고 가용 로그 임금은 3,010개, 미관측은 603개입니다. 보관 요약은 가용값을 모두 읽어 평균 269258772463/43000000000, 약 6.261831917744186을 계산합니다. 이 수는 1976년 시간당 센트 임금의 원 극단값 정리 로그 변수 평균입니다.
여기서 평균 로그를 보통 임금 평균으로 바꾸지 않습니다. 단순 지수화는 다른 함수이며, 결측 603명에 대한 평균도 알 수 없습니다. 기존 사례의 두 언어×두 출발 폴더 네 실제 실행과 이 장에서 추가한 검사 실행은 별도 기록입니다.
The Card source retains 3,613 person rows: 3,010 available log wages and 603 missing. The summary uses all available values, producing 269258772463/43000000000≈6.261831917744186. This is the source’s trimmed log of 1976 hourly wages in cents.
It is not an arithmetic mean wage. Exponentiation is another transformation, and the missing group’s mean is unknown. The case’s four archived runs across two languages/two launch folders are distinct from this chapter’s additional check scenarios.
점포 원자료에는 410행, 양 시점 FTE가 모두 있는 완전짝 384개가 있습니다. 원 점포 코드는 409개뿐이고 코드 407은 원행 42와 168에 각각 나타납니다. 같은 코드라는 이유로 두 기록을 하나로 지우지 않습니다.
원행 키는 이 보관 원파일의 순서를 추적하는 키입니다. 영구 사업체 식별자로 인증된 것이 아닙니다. 전체 행 정렬은 키·전·후 값을 함께 옮기며, 결측이 있는 나머지 26행도 보존합니다. 위치 번호는 정렬에 따라 바뀌어도 원행 키는 덮어쓰지 않습니다.
The store source has 410 rows and 384 complete before/after FTE pairs. There are only 409 distinct original store codes: code 407 appears in source rows 42 and 168. Equal codes do not justify deleting either record.
A source-row key traces position in this retained source file; it is not certified as a permanent establishment identifier. Whole-row sorting moves key, before and after together and retains the 26 incomplete rows. Display positions may change; provenance keys remain.
기초Foundations
44. 평균이 같아도 관측 짝은 틀릴 수 있다44. A matching mean can hide invalid pairing
실제 비교의 고의 오류는 후 열만 (원 점포 코드, 원행 키) 순서로 재배열하고 전 열은 원순서로 두는 것입니다. 후 FTE 수치의 크기순 정렬이 아닙니다. 새로 측정한 다른 자료가 아니라 잘못된 대응을 보여 주는 시연입니다.
384개 완전짝의 평균 변화는 올바른 짝과 고의 오류 모두 −541/7680 FTE입니다. 후 값의 합과 전 값의 합이 각각 같아서 그렇습니다. 그러나 개별 변화 374개가 달라지고 표본분산은 각각 4788802103/58828800과 11332726583/58828800 FTE²로 달라집니다. 평균 일치만으로 짝짓기를 검사할 수 없습니다.
The deliberate error reorders only the after column by original store code and source-row key, leaving before in source order. It is not sorting by numerical after FTE. This is an invalid correspondence demonstration, not another observed dataset.
Both versions yield mean change −541/7680 FTE across 384 complete pairs because the before and after sums separately remain unchanged. Yet 374 individual changes differ, and sample variances become 4788802103/58828800 versus 11332726583/58828800 FTE². Matching means cannot verify pairing.
기초Foundations
45. 실습 F: 실제 파일의 증거를 연결한다45. Lab F: connect evidence from actual files
국가는 사본의 바이트와 키·값 비교, 사람은 전체·가용·미관측 분모와 네 실제 실행, 점포는 전체 행 보존과 고의 짝 오류를 봅니다. 표의 값은 보관된 실제 자료 또는 명시한 오류 시연이며 새로운 관측이 아닙니다.
점포의 고의 오류 선택은 올바른 대안 분석으로 제시하지 않습니다. 개별 대응을 깨면 평균이 우연히 그대로여도 실제 관측 변화라는 해석은 사용할 수 없습니다.
Inspect country byte/key-value identity, person total/available/missing counts and four actual runs, and store whole-row preservation versus deliberate pairing error. Values are retained actual data or the explicitly invalid demonstration, not new observations.
The invalid store choice is not a legitimate alternative analysis. Breaking correspondence removes the observed-change interpretation even when its mean happens to remain unchanged.
기초Foundations
46. 실제 국가·사람·점포의 상세 사례46. Detailed country, person and store cases
국가 사례 · 파일 해시는 다른데 분석값은 같다
World Bank 실제2024년 선택16국 GDPpc를 원 API 행 위치·ISO·연도·지표·단위와 함께 보존합니다. 원자료를 덮어쓰지 않고 같은16행을 LF 줄바꿈 파일과 CRLF 줄바꿈 파일로 각각 썼습니다. 원 단위는2015년 불변 USD/인입니다. 다음 표의 크기·SHA256은 실제로 만든 작업 사본의 바이트에서 계산했습니다.
실제 두 작업 사본 · 같은 셀, 다른 바이트
작업 사본
바이트
바이트 SHA256 앞16자
정한 키·값 checksum 앞16자
working-country-same-cells-LF.csv
1163
92f9a84385f3bc4d
22a1bce0cbf60a57
working-country-same-cells-CRLF.csv
1180
193930430537c38d
22a1bce0cbf60a57
파일 해시는 바이트에 대한 요약입니다. 줄바꿈만 달라도 바뀔 수 있습니다. 반면 여기 정한 정규화 checksum은 지정한 키 순서로 행을 정렬하고 GDP 십진값을 정확한 유리수로 정리한 뒤 이름 붙인 필드를 비교합니다. 이 제한된 규칙에서 두 작업 파일이 같은 값을 갖는지 확인한 것입니다. 해시가 같다는 사실만으로 원자료가 권위 있거나 측정값이 참이라고 인증되는 것은 아니며, 선택한 checksum이 모든 의미의 동일성을 판정하는 것도 아닙니다.
먼저 생각한 뒤 풀이 보기: 파일 이름을 final_final2.csv로 바꾸면 버전 기록이 충분한가요?
아닙니다. 어떤 원본에서 어떤 코드·옵션으로 만들었고 무엇이 달라졌는지 기록해야 합니다. 파일 이름만 바꿔도 내용이 같을 수 있고 같은 이름의 내용이 달라질 수도 있습니다. 원본과 작업 사본·결과를 나누고 입력·코드 해시와 실행 환경을 함께 보존하세요.
사람 사례 · 다른 폴더에서 실행해도 같은 분모를 읽는가?
Card 실제 원3613행에서 가용3010개와 결측603개를 보존한 CSV를 사용합니다. 변수는1976년 시간당 임금(센트)의 원 극단값 정리 로그 값입니다. 스크립트의 위치를 기준으로 입력 경로를 만들고 Python과 R을 각각 두 다른 작업 폴더에서 새 프로세스로 실행했습니다. 네 번 모두3010개를 분모로 삼아 평균 약 6.261831918를 얻었습니다. 단순히 이전 화면의 출력을 복사한 것이 아닙니다.
현재 폴더와 스크립트 폴더는 다를 수 있습니다. Python 스크립트에서는 __file__로 위치를 얻지만 일반 노트북 셀에 그 이름이 자동으로 있다고 가정하지 않습니다. R 실행 파일도 --file 인자에서 스크립트 위치를 찾습니다. 제공한 manifest에는 실제 입력·코드 해시·출력·오류·런타임 기록이 들어 있고, 다운로드한 probe는 원본을 수정하지 않습니다.
함께 제공한 .ipynb는 실행 전 소스 예시이며 execution_count=null·outputs=[]입니다. JSON 구조와 Python 소스 구문을 검사했지만 Jupyter 커널에서 실행했다고 주장하지 않습니다. 노트북을 쓰려면 그 파일의 안내대로 작업 폴더와 호환 커널을 정하고 새 커널에서 위→아래로 실행해야 합니다. 저장된 출력이나 실행 번호는 문서 속 필드이므로 그것만으로 재실행의 독립 증거가 되지 않습니다. 이 장의 실제 실행 검증은 Python/R 스크립트 네 번과 별도 재현 코드입니다.
먼저 생각한 뒤 풀이 보기: 같은 코드와 같은 데이터로 다시 실행되면 새 연구가 반복 검증된 건가요?
이는 계산 재현의 중요한 한 단계입니다. 같은 입력·절차에서 같은 결과를 얻었다는 뜻이며 다른 사람·시기·현장에서 새 자료를 모아 실증 결과를 반복했다는 뜻은 아닙니다. 틀린 가정이나 표집 편향이 같은 코드에서 반복될 수도 있어 자료·모형의 타당성도 따로 평가합니다.
점포 사례 · 정렬한 새 버전에서도 짝은 원행 키로 보존한다
NJ/PA 실제410개 원행을 전체 행 단위로 정렬한 작업 사본을 만듭니다. 파일 바이트 해시는 달라지지만 원행 키와 같은 행의 전후 FTE를 함께 옮겼으므로 정한 키·값 checksum은 같습니다. source_row_id는 보관한 원 파일 위치이지 새 파일의 현재 줄 번호가 아닙니다. 코드407은 원행42·168에 모두 남기며 이 코드를 고유 키로 둔갑시키지 않습니다.
실제 전체행 정렬 사본의 기록
사본
행 수
완전짝
고유 원 코드
바이트 SHA 앞16자
키·값 SHA 앞16자
working-stores-original-order.csv
410
384
409
55195788fd001113
29147682caa95e91
working-stores-sorted-whole-rows.csv
410
384
409
7f8ee4ee490a94b1
29147682caa95e91
일부러 잘못된 비교 계산도 만듭니다. 완전짝384개를 원 점포 코드·원행 키(source_row_id)의 오름차순으로 정렬한 순서에서 후 시점 열만 가져오고, 전 시점 열은 원 순서를 유지한 채 위치로 빼 보았습니다. 후 FTE 숫자 자체의 크기순 정렬이 아닙니다. 이것은 실제 점포의 새 관측이 아니라 무효한 짝짓기 오류 시연입니다. 374개 변화값이 달라졌는데도 전체 평균 변화는 정확히 같습니다. 순열은 전후 합을 바꾸지 않기 때문입니다. 평균만 검사하면 이 오류를 놓치지만 짝별 값·변화 분산은 달라집니다.
정상 짝과 무효 시연 · 소수 반올림
규칙
평균 변화 FTE
변화 표본분산 FTE²
정상과 다른 변화값 수
정상 원행 짝
-0.070442708
81.402342
0
일부러 틀린 위치 짝
-0.070442708
192.639091
374
먼저 생각한 뒤 풀이 보기: Git에 커밋했으니 지금 화면의 마지막 수정도 저장됐나요?
반드시 그렇지는 않습니다. 작업 파일·스테이징한 내용·커밋한 스냅샷을 구별해야 합니다. add 뒤 다시 고친 내용은 다시 스테이징하지 않으면 이전 버전이 커밋될 수 있습니다. 이 장에서는 실제 연구 저장소의 과거 이력을 꾸미거나 바꾸지 않고, 현재 작업 사본과 코드·입력 해시를 명시적으로 기록했습니다. 해시와 버전 기록은 분석의 옳음을 대신하지 않습니다.
Country case · Different file hashes, equal analytical values
Preserve actual 2024 GDPpc for sixteen selected World Bank countries with archived API positions, ISO, year, indicator and units. Without overwriting originals, write the same sixteen records using LF and CRLF line endings. Source units are constant-2015 USD/person. The byte sizes and SHA256 values below are calculated from the actual working copies.
Two actual working copies · equal cells, different bytes
Working copy
Bytes
Byte SHA256 first 16
Specified key/value checksum first 16
working-country-same-cells-LF.csv
1163
92f9a84385f3bc4d
22a1bce0cbf60a57
working-country-same-cells-CRLF.csv
1180
193930430537c38d
22a1bce0cbf60a57
A file hash summarizes bytes, so line endings alone can change it. Our separately specified canonical checksum sorts by selected keys and normalizes GDP decimal values to exact rationals before comparing named fields. It checks equivalence under that limited rule. A matching hash does not certify source authority or measurement truth, and this chosen checksum does not determine every kind of semantic equivalence.
Think first, then reveal: Is renaming a file final_final2.csv sufficient version history?
No. Record its source, code/options and what changed. Different names can contain identical bytes, and the same name can later contain different bytes. Separate originals, working copies and outputs, retaining input/code hashes and execution context.
Person case · Does another launch folder read the same denominator?
Use the actual 3613-row Card source, retaining 3010 available and 603 unavailable source-trimmed logs of 1976 hourly wages in cents/hour. Anchor input paths to the script location, then launch fresh Python and R processes from two different working directories. All four executions use 3010 as the denominator and obtain mean approximately 6.261831918. These are actual reruns, not copied prior displays.
Actual fresh-process execution records · rounded mean
Language
Launch folder label
Rows
Valid
Missing
Return code
Mean
python
workspace
3613
3010
603
0
6.261831918
python
different_subfolder
3613
3010
603
0
6.261831918
r
workspace
3613
3010
603
0
6.261831918
r
different_subfolder
3613
3010
603
0
6.261831918
The current directory can differ from the script directory. Python scripts can use __file__; ordinary notebook cells should not assume that name exists. The R probe obtains its script location from the --file argument. The manifest preserves actual input/code hashes, outputs, errors and runtime information. Downloaded probes do not edit originals.
The provided .ipynb is an unexecuted source example, with execution_count=null and outputs=[]. Its JSON structure and Python syntax were checked, but no Jupyter-kernel execution is claimed. To use it, follow its working-directory instructions and run top to bottom in a fresh compatible kernel. Saved outputs or execution numbers are document fields, not independent evidence of rerunning. Actual execution checks here are the four Python/R script launches and separate companions.
Think first, then reveal: Does rerunning the same code and data constitute independent empirical replication?
It is an important computational reproduction check, not a new sample from other people, times or settings. Incorrect assumptions or selection bias can reproduce perfectly. Assess data and model validity separately.
Establishment case · Preserve keyed pairs when a new version reorders rows
Create a working copy that sorts all 410 actual NJ/PA records as whole rows. Its byte hash changes, but our specified key/value checksum stays equal because original source keys and both FTE waves move together. source_row_id denotes a position in the archived original, not the new file’s current line number. Preserve both 407 rows 42/168; the original code is not a unique key.
Records in actual whole-row sorted copies
Copy
Rows
Complete pairs
Distinct codes
Byte SHA first 16
Key/value SHA first 16
working-stores-original-order.csv
410
384
409
55195788fd001113
29147682caa95e91
working-stores-sorted-whole-rows.csv
410
384
409
7f8ee4ee490a94b1
29147682caa95e91
Construct an explicitly invalid comparison: reorder the 384 complete records by ascending original store code and source_row_id, take only their after-wave column in that order, keep the before-wave column in original source order, then subtract by position. This is not a numeric sort of the FTE values. It is an invalid-pairing demonstration, not new observations of establishments. It changes 374 change values while leaving the overall mean change exactly equal, because permutation preserves before/after sums. A mean-only check misses the error; keyed values and change variance expose it.
Valid pairing versus invalid demonstration · rounded
Rule
Mean change FTE
Sample variance of change FTE²
Changed values versus valid pairing
Valid source-row pairs
-0.070442708
81.402342
0
Deliberately invalid positional pairs
-0.070442708
192.639091
374
Think first, then reveal: Does a Git commit necessarily include the last edit now visible in a file?
No. Distinguish the working file, staged content and committed snapshot. Edits made after add may be absent unless staged again. This chapter does not fabricate or mutate research repository history; it records actual working copies and code/input hashes. Version records do not substitute for analytical validity.
심화Extension
47. 심화: 재현을 의존 관계로 설명한다47. Advanced: explain reproduction through dependencies
결과를 코드·입력·환경·실행 인자의 함수라고 생각하면 바뀐 의존성을 찾기 쉽습니다. 하지만 실제 프로그램은 외부 상태도 읽을 수 있으므로, 선언하지 않은 의존성이 있으면 이 모형이 빠집니다. 보관 실행은 선언한 유한 경로의 증거이지 모든 가능한 환경의 동작을 증명하지 않습니다.
감사에서는 주장과 근거를 연결합니다. ‘같은 바이트’에는 파일 해시, ‘같은 원행 대응’에는 키 검사, ‘실제 실행’에는 프로세스 기록, ‘같은 통계량’에는 독립 계산이 필요합니다. 한 가지 근거를 다른 주장에 무제한 확장하지 않는 것이 대학원 수준의 재현 논의로 이어집니다.
Model an output as depending on code, input, environment and arguments. Undeclared external state reveals an incomplete dependency model. Archived runs establish evidence for declared finite paths, not every possible environment.
Match claims to evidence: hashes for byte identity, key checks for correspondence, process records for actual execution and independent calculation for statistics. Restricting evidence to the claim it supports is a foundation for graduate-level reproducibility audits.
기초Foundations
48. 공식 읽기와 재실행 설명서를 만든다48. Read primary sources and write a rerun guide
Python pathlib에서는 기본 사용·현재 폴더·resolve를, hashlib에서는 bytes의 SHA-256 사용을 읽습니다. 웹의 패치 버전은 실제 보관 실행의 3.12.14와 다를 수 있습니다. R 공식 입문서의 파일 읽기와 스크립트 실행도 실행 버전 4.5.1과 구별합니다.
Read basic usage, current directory and resolve in Python pathlib, and SHA-256 on bytes in hashlib. Website patch versions may differ from recorded Python 3.12.14. Likewise distinguish file reading and script guidance in the R introduction from the recorded R 4.5.1 runtime.
Write a colleague’s rerun guide: one command, base directory, input/code identifiers, expected denominators and failure conditions. The next chapter develops CSV, dictionaries, dates, units and encoding.
자료 묶음을 풀고 코드와 실제데이터 폴더를 함께 두세요. 터미널에서 코드 파일이 있는 폴더로 이동해 아래 명령을 실행합니다. 코딩이 처음이라면 손계산과 웹 실습을 먼저 하고, 데이터 사이언스 입문에서 코드를 배운 뒤 돌아와도 됩니다.Extract the bundle, keeping the scripts beside the data folder. In a terminal, enter the script folder and run the commands below. Beginners can complete hand calculations and browser labs first, returning to code after studying introductory data science.
결과 파일은 각 코드에 지정된 결과 폴더에 저장됩니다. CSV 원자료는 덮어쓰지 않습니다.Result files are saved in the result directory specified by each script; the input CSVs are not overwritten.
영상·학자·함께 읽기Videos, thinkers and guided reading
본문의 질문을 넓히는 선택 학습입니다. 영상을 보기 전 질문을 먼저 읽고, 자신의 답을 쓴 뒤 해설과 비교하세요. 자료의 언어·선수 지식은 각 항목에 표시했습니다.Optional extensions to the chapter. Read the question first, write your answer, then compare with the explanation. Language and prerequisites are indicated below.
파일·폴더의 스냅샷과 이력 모형을 보고 작업 파일·스테이징·커밋을 구별합니다. 실제 공공자료 작업 사본에서 무엇을 기록해야 재현할 수 있는지 함께 적어 보세요.Use the snapshot/history model to distinguish working files, staging and commits, then list what must be recorded for these public-data working copies.
교재 안의 YouTube 플레이어에서 재생합니다. 원영상에서 제공하는 자막은 플레이어의 CC·설정에서 선택할 수 있습니다.Playback stays in this chapter’s YouTube player. Available captions can be selected through CC/settings.
보고 읽은 뒤 답하기Respond after watching/reading커밋 해시와 CSV의 SHA256은 같은 대상인가요?Does a commit hash identify the same object as a CSV SHA256?
생각을 점검하는 해설Check your reasoning
아닙니다. 커밋은 트리·메타데이터·부모 관계를 포함한 버전 객체이고 CSV 해시는 해당 파일 바이트에 대한 요약입니다.No. A commit identifies a version object including tree, metadata and parent relationships; a CSV hash summarizes that file’s bytes.
페르난도 페레스 · 대화형 계산과 열린 과학Fernando Pérez · Interactive computing and open science
Berkeley Institute for Data Science · official profile
IPython과 Jupyter를 연결한 공식 소개를 읽으며 설명·코드·출력을 한 문서에 담는 장점과 실행 상태를 다시 확인할 책임을 함께 생각합니다.Read the official IPython/Jupyter account, considering both the benefit of combining explanations, code and output and the responsibility to verify execution state.
보고 읽은 뒤 답하기Respond after watching/reading노트북이 있으면 실행 환경 기록은 생략해도 될까요?Does having a notebook remove the need to record its environment?
생각을 점검하는 해설Check your reasoning
아닙니다. 커널·언어·패키지·입력 파일·실행 순서·경로가 결과에 영향을 줄 수 있습니다.No. Kernel, language, packages, inputs, order and paths can affect results.
Jupyter 공식 · 노트북 파일의 소스와 출력Official Jupyter · Notebook sources and outputs
nbformat official specification · top-level/code-cell fields
cells·source·outputs·execution_count 필드를 읽고 실행 전 예시의 null·빈 출력을 확인합니다. 저장된 필드와 실제 새 커널 실행을 구별하세요.Read cells, source, outputs and execution_count, checking the null counts and empty outputs in the unexecuted example. Separate saved fields from actual fresh-kernel execution.
보고 읽은 뒤 답하기Respond after watching/reading소스가 맞아 보이면 저장된 출력도 최신인가요?Does plausible source guarantee up-to-date saved output?
생각을 점검하는 해설Check your reasoning
아닙니다. 실제 입력·환경에서 새 실행으로 다시 확인해야 합니다.No. Verify by rerunning with the actual inputs and environment.
Git 공식 · 지금 파일과 스테이징한 파일Official Git · Working content versus staged content
Pro Git 2 · tracking and staging changes
새 파일 추적과 수정 파일 스테이징, add 뒤 다시 수정한 예를 읽습니다. 본문의 데이터 사본·실행 결과 기록과 연결하되 저장 이력이 분석의 타당성을 인증한다고 읽지 않습니다.Read tracking, staging and editing after add. Connect this with artifact records without treating history as proof of analytical validity.
보고 읽은 뒤 답하기Respond after watching/reading작업 폴더에 파일이 있으면 자동으로 다음 커밋에 들어가나요?Does a file in the working folder automatically enter the next commit?
생각을 점검하는 해설Check your reasoning
아닙니다. 추적·스테이징 상태와 실제 포함할 내용을 확인해야 합니다.No. Check tracking, staging and the content actually included.
연습문제 · 계산에서 설명과 증명까지Exercises: calculation, explanation and proof
먼저 혼자 풀고 풀이를 여세요. 숫자와 함께 단위·포함 기준·계산 이유를 확인하세요.Attempt each problem before opening its solution. Check units, inclusion rules and the reason for the calculation.
1. 파일은 있지만 이름은 없다A file without a binding
디스크에 values.csv가 있습니다. 새 Python 프로세스에서 읽기 명령 없이 rows를 출력하면 자동으로 파일 내용이 나오나요? 필요한 단계를 설명하세요.
values.csv exists on disk. Does a fresh Python process automatically display it when asked for rows, before any reading command? Explain the missing steps.
풀이와 확인할 이유Solution and explanation
아닙니다. 파일 존재와 메모리 이름은 다릅니다. 파일 경로를 정하고 읽어 해석한 결과를 rows에 연결한 뒤 출력해야 합니다. 어제의 프로세스에 있던 이름을 오늘의 새 프로세스가 자동으로 갖는다고 가정하지 않습니다.
No. Choose the path, read and interpret the file, then bind the result to rows. Disk existence and a process binding are distinct. Yesterday’s binding is not automatically present in a fresh process.
2. 메모리를 바꾸면 원파일도 바뀔까Does changing memory change the file?
파일의 값은 2,4,6입니다. 읽어 만든 rows를 10,20으로 바꿨지만 쓰기 명령은 실행하지 않았습니다. 파일과 rows에는 각각 무엇이 남나요?
A file holds 2,4,6. After reading it, replace rows by 10,20 without executing a write. What remains in each place?
풀이와 확인할 이유Solution and explanation
파일에는 2,4,6, 메모리 rows에는 10,20이 남습니다. 재할당이 원파일 쓰기를 뜻하지 않습니다. 파일을 바꾸려면 별도의 명시적 쓰기와 덮어쓰기 정책이 필요합니다.
The file retains 2,4,6 while rows contains 10,20. Rebinding is not a file write. Changing a file requires an explicit write and an appropriate overwrite policy.
3. 폴더 지도의 상대 경로A relative path in a folder map
project/input/values.csv가 있고 현재 폴더는 project입니다. input/values.csv는 어디를 가리키나요? 현재 폴더를 project/nested로 바꾸면요?
The file is project/input/values.csv. Resolve input/values.csv from project, then from project/nested.
풀이와 확인할 이유Solution and explanation
처음에는 project/input/values.csv, 다음에는 project/nested/input/values.csv입니다. 같은 상대 경로 문자열도 기준 폴더에 따라 대상이 다릅니다.
The targets are project/input/values.csv and project/nested/input/values.csv. Identical relative text can identify different targets when the base changes.
4. 코드 위치와 출발점Script location and launch location
analysis.py는 project에 있고 입력은 project/input/values.csv입니다. nested에서 실행할 때 코드 위치 기준과 현재 폴더 기준 중 어느 것이 이 파일을 찾나요?
analysis.py is in project and its input in project/input/values.csv. Launch from nested. Which declared base finds this input?
풀이와 확인할 이유Solution and explanation
이 선언한 구조에서는 코드 위치 기준이 찾습니다. 현재 폴더 기준은 nested/input을 찾으므로 실패합니다. 이것은 모든 프로젝트가 코드 기준을 써야 한다는 명제가 아니라 이번 경로 계약의 결과입니다.
The script-directory base finds it; the cwd base requests nested/input and fails. This follows from the declared layout, not a rule that every project must use script-relative input.
5. 절대 경로의 이식성Portability of a personal absolute path
동료에게 내 계정의 절대 경로 하나만 박아 넣은 코드를 보냈습니다. 상대 경로로만 바꾸면 충분한가요?
You share code containing a personal absolute path. Is merely replacing it by relative text enough?
풀이와 확인할 이유Solution and explanation
출발점이 선언되지 않으면 충분하지 않습니다. 프로젝트 기준이나 코드 기준을 정하고 폴더 구조를 함께 전달하거나 입력 인자를 받습니다. 공백이 있는 경로는 명령 인자로 따옴표 처리합니다.
Not without a declared base. Supply a project/script base and folder structure, or accept an input argument. Quote paths containing spaces when passing command arguments.
6. 없는 입력과 빈 입력Absent input versus empty input
프로그램이 요청한 input/values.csv가 없습니다. 빈 벡터를 만든 뒤 평균 0을 성공으로 출력해도 되나요?
The requested input/values.csv does not exist. May the program silently create an empty vector and report mean zero as success?
풀이와 확인할 이유Solution and explanation
안 됩니다. 파일 조회 실패와 관측값이 0인 자료는 다릅니다. 입력 부재를 명시하고 실패 상태로 멈춥니다. 빈 자료 평균도 별도 미정의 상태로 다뤄야 하며 0으로 자동 대체하지 않습니다.
No. Failed lookup differs from observed zero. Report the absent input and failure. An empty-data mean also requires an explicit undefined state rather than automatic zero filling.
7. 상위 폴더 표기의 주의A parent-directory caution
경로 a/../b에서 문자열 a/..를 지우는 것과 실제 파일 시스템 경로를 해석하는 것은 언제나 같나요?
Is deleting a/.. from path text always equivalent to resolving a real filesystem path?
풀이와 확인할 이유Solution and explanation
그렇지 않습니다. 심볼릭 링크 등 파일 시스템 관계가 있으면 순수 문자열 축약과 실제 해석이 다를 수 있습니다. 사용한 플랫폼·경로 함수·해석 기준을 확인합니다.
No. Symbolic links and filesystem relationships can make textual reduction differ from actual resolution. Check the platform and path operation rather than treating all normalization as string editing.
8. 경로 실습의 실행 범위Execution scope of the path lab
브라우저에서 Python·nested·cwd를 골라 오류 기록을 보았습니다. 브라우저가 지금 내 컴퓨터에서 Python을 실행한 것인가요?
You select Python, nested and cwd and see an error. Did the browser just start Python on your computer?
풀이와 확인할 이유Solution and explanation
아닙니다. 실제로 미리 실행한 고정 기록을 선택한 것입니다. 새 코드를 실행하려면 보관 파일을 내려받아 자신의 새 프로세스에서 실행해야 합니다.
No. It selected an archived actual run. New code must be executed separately in a fresh process using the downloaded files.
9. 같은 크기와 다른 값Same size, different value
가정 CSV의 값 4를 5로 바꾸었더니 파일 바이트 수는 같습니다. 내용도 같다고 결론낼 수 있나요?
Changing toy CSV value 4 to 5 leaves the byte count unchanged. Must its content be unchanged?
풀이와 확인할 이유Solution and explanation
아닙니다. 같은 길이의 다른 숫자로 바꾸면 크기를 유지할 수 있습니다. 바이트 해시와 값 비교는 크기 비교보다 구체적이며, 이 경우 실제 기록 값이 달라졌습니다.
No. Equal-length edits can preserve size. Byte hashes and value comparisons are more specific; this edit changes a recorded value.
10. 17바이트의 차이A seventeen-byte difference
실제 국가 사본은 LF 1,163바이트, CRLF 1,180바이트입니다. 다른 변화 없이 LF 한 바이트를 CRLF 두 바이트로 바꿨다면 줄 끝은 몇 개인가요?
Actual country copies have 1,163 LF bytes and 1,180 CRLF bytes. If each changed ending adds one byte and nothing else changes, how many endings are there?
풀이와 확인할 이유Solution and explanation
차이 1180−1163=17바이트이며 줄 끝마다 한 바이트가 늘었으므로 17개입니다. 국가 관측은 머리글을 제외한 16개입니다. 모든 일반 파일도 마지막 줄 끝이 있다는 뜻은 아닙니다.
There are seventeen endings because 1180−1163=17. The data retain sixteen country observations plus a header line. This does not imply every file ends with a newline.
11. 해시와 수치 비교Hashes and numerical comparison
LF와 CRLF 국가 사본의 SHA-256이 다르지만 지정 키·값 비교는 같습니다. 두 검사 중 하나가 반드시 틀렸나요?
LF and CRLF hashes differ while declared key/value comparison agrees. Must one check be wrong?
풀이와 확인할 이유Solution and explanation
아닙니다. 해시는 바이트를, 지정 규칙은 줄 끝을 무시한 기록을 비교합니다. 서로 다른 질문에 일관된 답입니다. 어떤 정보를 무시했는지 함께 설명해야 합니다.
No. The byte comparison and the record comparison answer different questions. Explain that the latter disregards line endings under its declared rule.
12. 같은 해시의 주장 범위The scope of a matching hash
입력과 코드 해시가 보관 기록과 일치합니다. 원자료 측정과 정책 인과 해석까지 인증되나요?
Input and code hashes match a retained run. Does this certify measurement or causal policy interpretation?
풀이와 확인할 이유Solution and explanation
그렇지 않습니다. 바이트 식별의 강한 실무 근거이며 측정·표집·식별 가정은 별도입니다. 같은 틀린 짝짓기 코드도 같은 입력에서 반복될 수 있습니다.
No. It is strong practical content-identification evidence. Measurement, sampling and identification assumptions are separate, and an invalid pairing can be reproduced.
13. 순서를 무시할 수 없는 자료When order matters
순차 누적합을 분석하는 시계열에서 값들의 순서를 무시한 정규화 해시가 같습니다. 누적합 경로도 같나요?
Two time-series files agree under an order-insensitive rule. Must their cumulative-sum paths agree?
풀이와 확인할 이유Solution and explanation
일반적으로 다릅니다. 예를 들어 1,−1의 누적합은 1,0이고 −1,1은 −1,0입니다. 최종 합이 같아도 경로는 다릅니다. 분석에 필요한 순서를 비교 규칙에서 보존해야 합니다.
No. Values 1,−1 give cumulative sums 1,0, while −1,1 give −1,0. Preserve order whenever the analysis depends on the path.
14. 전체 행의 순열A permutation of whole records
원행 키가 붙은 (키,전,후) 전체 행을 한 순열로 옮겼습니다. 대응을 보존하는 이유와 현재 위치의 변화를 설명하세요.
Apply one permutation to complete (key, before, after) rows. Why are pairs preserved, and what can change?
풀이와 확인할 이유Solution and explanation
각 키와 전·후 값이 같은 묶음으로 이동하므로 관측 대응은 유지됩니다. 화면 위치는 바뀔 수 있지만 원행 키는 그대로입니다. 새 위치 번호로 원행 키를 덮어쓰지 않습니다.
Each key moves with its before/after fields, preserving correspondence. Display positions can change while source keys remain. Do not replace provenance keys by new ranks.
15. 평균을 속이는 두 짝Two pairings with one mean
가정 전 값 (1,10), 후 값 (3,11)에서 올바른 변화와 후 값만 뒤집은 변화를 계산하세요. 각각 평균은요?
Toy before values are (1,10), after (3,11). Compute changes correctly and after reversing only after. Compare means.
풀이와 확인할 이유Solution and explanation
올바른 변화는 (2,1), 고의 오류는 (10,−7)입니다. 합은 모두 3, 평균은 모두 1.5입니다. 평균 일치가 개별 짝의 타당성을 보장하지 않습니다.
Correct changes are (2,1); the invalid changes are (10,−7). Both sum to three and average 1.5. A matching mean does not validate correspondence.
16. 두 짝의 분산Variances of the two pairings
앞 문제와 독립적으로 변화 (2,1)과 (10,−7)의 분모 n−1 표본분산을 계산하세요. n=2입니다.
Compute n−1 sample variances for changes (2,1) and (10,−7), each with n=2.
풀이와 확인할 이유Solution and explanation
두 평균은 1.5입니다. 첫 제곱편차합은 .25+.25=.5, 둘째는 72.25+72.25=144.5입니다. n−1=1로 나눠 각각 .5와144.5입니다. 같은 평균과 다른 분산이 동시에 가능합니다.
Both means are 1.5. Squared deviations sum to .5 and 144.5 respectively. Dividing by n−1=1 gives those sample variances. Equal means can coexist with very different variation.
17. 새 파일과 준비 영역A new file and the index
새 analysis.py에 v1을 저장했지만 git add는 하지 않았습니다. 작업·준비·HEAD 파일은 각각 어떤 상태인가요? 아직 첫 커밋 전입니다.
Save v 1 as a new analysis.py before any add or first commit. What are working, index and HEAD states?
풀이와 확인할 이유Solution and explanation
작업에는 v1, 준비와 HEAD에는 해당 파일이 없습니다. 부재와 빈 파일은 다릅니다. 저장은 Git add나 실행을 대신하지 않습니다.
Working contains v 1. The index and HEAD have no such file. Absence is not an empty file, and saving is neither staging nor executing.
18. add의 시점The timing of add
작업 v1을 git add한 뒤 작업만 v2로 고쳤습니다. 아직 첫 커밋 전입니다. 바로 커밋하면 어느 내용이 들어가나요?
Stage working v 1, then edit only working to v 2 before the first commit. Which content is committed now?
풀이와 확인할 이유Solution and explanation
준비된 v1이 들어갑니다. add는 실행 당시 내용을 준비하며 나중 편집을 자동 반영하지 않습니다. v2를 기록하려면 다시 add해야 합니다.
The staged v 1. Add selects content at that time and does not automatically include subsequent edits. Stage again to commit v 2.
19. 첫 커밋 뒤 세 상태Three states after the first commit
v1을 준비한 뒤 작업을 v2로 바꾸고 첫 커밋을 했습니다. 세 상태를 적고 왜 작업이 남아 있는지 설명하세요.
Stage v 1, edit working to v 2, then commit. Give all three states and explain the remaining change.
풀이와 확인할 이유Solution and explanation
작업 v2·준비 v1·HEAD v1입니다. 커밋은 준비 내용을 기록하므로 준비되지 않은 작업 편집을 지우거나 커밋하지 않습니다. 이후 add와 새 커밋을 별도로 수행합니다.
Working is v 2, index v 1 and HEAD v 1. Committing the index does not discard or include an unstaged working edit. A later add and commit can record it.
20. 깨끗한 상태와 재현Clean status and reproduction
Git 상태가 깨끗하지만 분석 입력은 다른 외부 폴더에서 읽습니다. 실행 재현에 충분한가요?
Git status is clean, but analysis reads an external input. Is reproduction established?
풀이와 확인할 이유Solution and explanation
충분하지 않습니다. 외부 파일의 내용·경로·해시와 실행 환경·인자를 기록해야 합니다. 깨끗한 Git 상태는 추적한 내용과 준비·작업 관계에 대한 정보이며 외부 입력의 존재나 적합성을 증명하지 않습니다.
No. Record the external path/content hash and execution environment/arguments. Clean status describes tracked content states, not the existence or suitability of external inputs.
21. 커밋과 코드 실행A commit versus an execution
analysis.py를 add하고 커밋했지만 Python 명령은 실행하지 않았습니다. 계산 결과가 검증되었나요?
You add and commit analysis.py without invoking Python. Has its result been tested?
풀이와 확인할 이유Solution and explanation
아닙니다. 선택한 코드 내용을 기록했을 뿐입니다. 실제 실행 명령·입력·종료 상태·출력과 검사 결과가 별도로 필요합니다. 커밋 식별자를 프로세스 실행 증거로 쓰지 않습니다.
No. You recorded selected source content. Actual command, input, exit status, output and checks are separate evidence. A commit identifier is not an execution record.
22. 교육용 저장소의 이력History in a teaching repository
이 교재를 위해 오늘 새 저장소와 두 커밋을 만들었습니다. 실제 연구자가 수년간 작업한 이력이라고 소개해도 되나요?
A new repository and two commits were created today for this lesson. May they be presented as a researcher’s multiyear history?
풀이와 확인할 이유Solution and explanation
안 됩니다. 실제 Git을 사용한 교육용 시연이라고 명시합니다. 실행이 실제였다는 주장과 시연 내용이 실제 과거 연구 이력이라는 주장은 다릅니다.
No. They are an actual Git teaching demonstration. Genuine tool execution does not turn constructed examples into historical research activity.
23. 버전 기록과 백업Version history and backup
유일한 로컬 디스크에 Git 저장소 하나만 있습니다. 파일 변경 이력이 있으니 디스크 고장에도 보존된다고 볼 수 있나요?
The only copy of a Git repository is on one local disk. Does its history ensure survival of disk failure?
풀이와 확인할 이유Solution and explanation
아닙니다. 이력과 별도 장치·위치의 백업은 다른 개념입니다. 유일한 저장 장치를 잃으면 그 안의 저장소도 잃을 수 있습니다. 보존 정책과 복원 가능성을 별도로 확인합니다.
No. History and an independent backup differ. Losing the only storage device can lose the repository too. Examine preservation and restoration separately.
24. 실행 설명서의 일곱 항목Seven parts of a rerun guide
동료가 같은 스크립트를 처음부터 실행하도록 돕는 설명서에 필요한 일곱 항목을 제시하세요.
List seven items enabling a colleague to run a script from the beginning.
풀이와 확인할 이유Solution and explanation
입력 경로·해시, 코드 경로·해시, 실행 버전, 출발 폴더, 명령 인자, 종료 상태, stdout/stderr와 기대 검사값을 남깁니다. 필요하면 결과 파일 해시도 붙입니다. 로그의 범위를 과장하지 않습니다.
Retain input path/hash, code path/hash, runtime version, launch directory, arguments, exit status, and stdout/stderr with expected checks. Add output-file hashes when needed. State the recording scope.
25. 소스 노트북의 nullNull in a source notebook
코드 셀의 execution_count는 null이고 outputs는 []입니다. 실행 실패가 증명되나요?
A code cell has execution_count=null and outputs=[]. Does this prove execution failed?
풀이와 확인할 이유Solution and explanation
그 필드만으로 실패가 증명되지 않습니다. 이 장의 파일은 실행하지 않은 소스 전용 노트북입니다. 저장된 출력이 없다는 사실과 실행 실패 기록을 구별합니다.
No. Here it is a source-only unexecuted notebook. Absence of saved execution output differs from recorded execution failure.
26. 저장된 출력의 증거Evidence from a saved output
노트북에 평균 4가 저장되어 있습니다. 현재 입력 파일과 코드로 새 커널에서 실행했다는 충분한 증거인가요?
A notebook displays saved mean four. Is that enough to establish a fresh-kernel run on current input and code?
풀이와 확인할 이유Solution and explanation
아닙니다. 저장 출력은 과거 상태에서 남았을 수 있습니다. 입력·코드 식별과 실제 실행 순서·새 시작 기록이 필요합니다. 표시된 답 하나로 모든 의존성을 확인할 수 없습니다.
No. It may be retained output from an earlier state. Check input/code identifiers, actual order and fresh-start evidence. One displayed answer cannot establish every dependency.
27. 123의 마지막 상태Final state of 123
셀1 rows=[2,4,6], 셀2 answer=sum(rows)/len(rows), 셀3 rows=[10,20]입니다. 새 상태에서 123을 실행하면 마지막 rows와 answer는요?
Cell 1 sets rows=[2,4,6], cell 2 sets answer=sum (rows)/len (rows), and cell 3 sets rows=[10,20]. Give final rows and answer after fresh order 123.
풀이와 확인할 이유Solution and explanation
rows는 [10,20], answer는 4입니다. 마지막 입력 변경이 이미 저장한 평균을 자동 갱신하지 않습니다. 현재 입력 평균을 원하면 셀2를 다시 실행합니다.
Rows is [10,20] and answer four. Replacing input does not automatically update a stored mean. Run cell 2 again to summarize current rows.
28. 132의 마지막 상태Final state of 132
앞 문제와 독립적으로 셀1 rows=[2,4,6], 셀2 평균 answer 계산, 셀3 rows=[10,20]입니다. 132 실행의 answer는요?
Cell 1 sets rows=[2,4,6], cell 2 computes its mean answer, cell 3 sets rows=[10,20]. Find answer under order 132.
풀이와 확인할 이유Solution and explanation
15입니다. 셀1 다음 셀3이 입력을 10,20으로 바꾸고 셀2가 합30/길이2를 계산합니다. 123의 4와 다른 이유는 같은 셀의 다른 의존 순서입니다.
It is fifteen: cell 3 changes input before cell 2 computes 30/2. The difference from order 123 comes from dependency order, not different source cells.
29. 213의 실패 이력Failure history of 213
세 셀은 1:rows=[2,4,6],2:answer평균,3:rows=[10,20]입니다. 기록기는 오류를 잡고 계속합니다. 새 상태의 213에서 오류와 마지막 answer를 설명하세요.
Cells are 1: rows=[2,4,6], 2: compute answer mean, 3: rows=[10,20]. The recorder catches errors and continues. Describe fresh order 213.
풀이와 확인할 이유Solution and explanation
셀2는 rows 부재로 실패합니다. 셀1과 셀3은 뒤에 성공하지만 평균 셀을 다시 실행하지 않아 answer는 없습니다. 마지막 rows는10,20이며 뒤 성공이 앞 실패를 지우지 않습니다.
Cell 2 fails because rows is absent. Cells 1 and 3 then succeed, leaving rows [10,20] but no answer. Later success does not erase the initial error.
30. 312의 마지막 답The final answer for 312
셀1 rows=[2,4,6],셀2 평균 answer,셀3 rows=[10,20]을 새 상태에서 312로 실행합니다. 마지막 답은 왜15가 아닌가요?
Run cells 1: rows=[2,4,6], 2: mean answer, 3: rows=[10,20] in fresh order 312. Why is the answer not fifteen?
풀이와 확인할 이유Solution and explanation
셀3의10,20을 셀1이2,4,6으로 다시 바꾼 뒤 셀2가 계산하여4입니다. 처음 한 번 생긴 입력이 끝까지 유지된다고 가정하면 순서를 잘못 읽게 됩니다.
Cell 1 replaces cell 3’s values before cell 2 computes. The answer is four. A binding created early need not retain that value throughout the run.
31. 321의 오래된 답A stale answer under 321
같은 세 셀을 새 상태에서 321로 실행합니다. 셀3은10,20,셀2는평균,셀1은2,4,6을 저장합니다. 마지막 상태를 설명하세요.
Fresh order 321 first sets rows=[10,20], computes answer, then sets rows=[2,4,6]. Describe the final state.
풀이와 확인할 이유Solution and explanation
answer는15,rows는2,4,6입니다. 이번에도 계산 이후 입력을 바꿔 최신 입력의 평균과 저장 답이 다릅니다. 오류가 없다는 사실은 최신성 보장이 아닙니다.
Answer is fifteen while rows is [2,4,6]. Input changes after computation, so the stored answer is stale for current input despite the absence of an error.
32. 제어 규칙의 일반화Generalizing a recorder policy
추적기는 오류 셀 뒤 다음 셀을 실행합니다. 일반 처리하지 않은 Python/R 오류도 항상 계속된다고 결론낼 수 있나요?
The trace continues after a failed cell. Does every ordinary unhandled Python/R error continue execution?
풀이와 확인할 이유Solution and explanation
아닙니다. 기록기가 try/오류 처리로 계속하도록 만들었습니다. 일반 스크립트의 미처리 오류는 실행을 중단할 수 있습니다. 도구의 제어 규칙과 언어 일반 규칙을 구별합니다.
No. The recorder explicitly catches errors. An unhandled error in an ordinary script can stop it. The tool’s control policy is not a universal language rule.
33. 새 시작이 잡는 오류A problem exposed by a fresh start
빠진 rows 읽기 줄이 과거 세션에서는 문제없이 지나갔지만 새 프로세스에서는 이름 오류가 납니다. 무엇을 발견한 것인가요?
An omitted rows-loading line was unnoticed in an old session but raises a name error in a fresh process. What was found?
풀이와 확인할 이유Solution and explanation
과거 메모리에 남은 이름에 의존한 것입니다. 입력 읽기·정의·호출을 실행 파일에 명시하고 처음부터 다시 실행합니다. 평균 공식이 틀렸다는 반례는 아닙니다.
A dependency on leftover memory. Include loading, definitions and calls explicitly, then rerun from the beginning. This is not a counterexample to the mean formula.
34. 일반 프로세스와 JupyterOrdinary processes versus Jupyter
고정 세 셀을 실제 Python 새 프로세스에서 여섯 순서로 실행했습니다. Jupyter 커널 검증도 했다고 쓸 수 있나요?
The fixed cells ran in six orders in fresh Python processes. May this be called Jupyter-kernel validation?
풀이와 확인할 이유Solution and explanation
아닙니다. 일반 Python 실행 검증 범위를 그대로 적고 Jupyter 실행은 하지 않았다고 명시합니다. .ipynb JSON 형식 확인과 커널 실행도 별도입니다.
No. State ordinary-process execution and keep kernel execution false. Checking notebook JSON structure is another separate activity.
35. 명령 인자의 역할Roles of command arguments
summary.py --input people.csv --expect-total 3613에서 파일 경로와 검사값은 각각 무엇인가요?
In summary.py --input people.csv --expect-total 3613, identify the requested path and check value.
풀이와 확인할 이유Solution and explanation
people.csv는 요청 입력 경로이고3613은 예상 행 수 검사값입니다. 상대 경로는 실행 출발점을 기준으로 해석합니다. 코드 파일 경로와 입력 경로는 서로 다른 인자 역할입니다.
people.csv is the requested input and 3613 the expected-count check. Relative input uses the launch base. Script location and input location play different roles.
36. 3614라는 예상값An expectation of 3614
실제 파일3613행에 --expect-total 3614를 주었습니다. 오류를 없애려고 원자료에 한 행을 더하는 것이 적절한가요?
The actual file has 3613 rows but --expect-total is 3614. Should you add a source row to eliminate the error?
풀이와 확인할 이유Solution and explanation
아닙니다. 먼저 잘못된 예상값이나 잘못 선택한 파일을 조사합니다. 이 실행은 명시한 검사 실패를 보인 것이며 원자료 관측을 만들어 맞추는 근거가 아닙니다.
No. Investigate the expected count and selected input. A failed check is not justification for fabricating an observation.
37. 요청 경로와 참조 해시Requested path and reference hash
missing-input 기록에서 requestedInputFile은 없는 파일, inputFile/inputSha256은 보관 원CSV입니다. 어느 파일의 바이트를 해시했나요?
In a missing-input record, requestedInputFile is absent while inputFile/inputSha256 identify a retained CSV. What was hashed?
풀이와 확인할 이유Solution and explanation
존재하는 참조 원CSV를 해시했습니다. 없는 요청 파일의 해시라는 뜻이 아닙니다. UI와 실행 설명서에서 요청 경로와 참조 입력 식별값을 명확히 나눕니다.
The existing reference CSV, not the nonexistent request. Label requested location and reference-input identification separately.
38. 로그의 세 출구Three parts of a process result
실행 기록에는 stdout,stderr,종료 상태가 있습니다. stderr에 경고가 있으면 평균을 무조건 실패로,숫자가 나오면 무조건 성공으로 읽어도 되나요?
A record has stdout, stderr and exit status. Does any stderr warning mean failure, or any printed number mean success?
풀이와 확인할 이유Solution and explanation
둘 다 부적절합니다. 경고 내용,실제 종료 상태,출력 구조와 검사를 함께 읽습니다. 경고가 있는 성공 실행도 있고 일부 출력 뒤 실패하는 실행도 있을 수 있습니다.
Neither rule is sound. Inspect warning content, exit status, output structure and checks together. Successful runs can warn; failed runs can print partial output.
39. 가용0을 보존한다Preserve an observed zero
가정 입력은0,4,NA입니다. NA만 미관측일 때 가용 분모와 평균은요? 0도 없애면 무엇이 바뀌나요?
Toy input is 0,4, NA and only NA is missing. Find denominator and mean. What happens if zero is dropped too?
풀이와 확인할 이유Solution and explanation
가용2개,합4,평균2입니다.0을 없애면 분모1·평균4로 다른 질문이 됩니다. 수치0과 미관측 표식은 별개입니다.
Two available values sum to four and average two. Dropping zero changes the denominator to one and mean to four. Observed zero and missingness differ.
40. 전부 미관측인 요약A wholly missing summary
가정 CSV 세 행의 값이 모두NA입니다. 전체 수·가용 수·미관측 수와 평균 상태를 적으세요.
All three toy CSV values are NA. Give total, available, missing counts and mean status.
풀이와 확인할 이유Solution and explanation
전체3,가용0,미관측3이며 가용 평균은 미정의입니다. 코드가 null/NA처럼 명시한 상태로 표시하고 평균0이라는 관측 결과를 만들지 않습니다.
Total three, available zero, missing three; the available mean is undefined. Use an explicit null/NA status rather than fabricating a mean of zero.
41. 실제 사람 분모의 항등식An identity for actual person counts
실제 사람 전체3613행·가용 로그3010개입니다. 미관측 수를 구하고 가용 로그 평균에 사용할 분모를 설명하세요.
There are 3613 actual person rows and 3010 available logs. Find missing count and the available-mean denominator.
No. The exact fraction describes arithmetic on retained finite decimals; the displayed number approximates it. Original measurement, trimming and reporting precision remain separate.
43. 평균 로그의 의미Meaning of a mean log
실제 가용 평균은 약6.261831917744186이며 변수는1976년 센트/시간 임금의 원 정리 로그입니다. 이 수를 평균 달러/시간이라고 표기해도 되나요?
The actual available mean is about 6.261831917744186 for the source’s trimmed log hourly cents wage in 1976. May it be labeled mean dollars per hour?
풀이와 확인할 이유Solution and explanation
안 됩니다. 로그 변수 평균입니다. 지수화와통화 환산은 별도이며 일반적으로 평균 로그의 지수는 임금의 산술평균과 다릅니다. 결측 그룹의 평균도 알려주지 않습니다.
No. It is a mean log. Exponentiation and currency conversion are separate, and exponentiated mean log generally differs from arithmetic mean wage. It does not identify the missing group’s mean.
44. 언어 사이의 작은 차이Small cross-language differences
Python 정확분수의 실수 표시와R 평균의 마지막 자릿수가 다릅니다. 어떤 순서로 확인하겠나요?
The final digit differs between Python’s displayed fraction and R’s mean. What should be checked first?
풀이와 확인할 이유Solution and explanation
입력 해시,원행 선택,열과단위,가용분모를 먼저 맞춘 뒤 부동소수점·합산·출력 반올림을 봅니다. 단순히 표시가 다르다는 이유로 다른 모집단이라고 판단하지 않습니다.
Match input hash, selected rows, field, units and denominator before floating arithmetic, summation and display rounding. A final-digit difference alone does not establish different populations.
45. 410과384의 차이The difference between410 and384
실제 점포410행 중384완전짝입니다. 나머지는 몇 행이며 전체행 정렬 사본에서 지워도 되나요?
Of 410 actual store rows,384 are complete pairs. How many are incomplete, and should a whole-record sorting copy delete them?
풀이와 확인할 이유Solution and explanation
26행입니다. 전체 원기록 보존 사본에는 결측 필드와 함께 남깁니다. 완전짝 분석의 제외 정책은 별도로 밝힙니다. 정렬이라는 이유로 미관측행을 삭제하지 않습니다.
Twenty-six. Retain them with unavailable fields in the whole-record copy, while declaring exclusion from complete-pair analysis separately. Sorting does not justify deletion.
46. 중복 코드407Repeated code407
410원행에 서로 다른 점포 코드409개가 있고407은 원행42와168에 있습니다. 두 행을 하나로 합쳐도 되나요?
There are 410 rows but 409 distinct store codes;407 occurs in source rows 42 and 168. May they be merged?
풀이와 확인할 이유Solution and explanation
코드 중복만으로 합칠 근거는 없습니다. 두 원행을 각각 보존하고 원행 키와 원코드의 역할을 구별합니다. 영구 사업체 동일성을 이 기록만으로 인증하지 않습니다.
Code equality alone is insufficient. Preserve both records and distinguish provenance row keys from original codes. These fields do not themselves certify permanent establishment identity.
47. 정렬 뒤 첫 위치First position after sorting
원행 42의 변화는 0, 원행 168의 변화는 2.5 FTE입니다. 이 두 행만 대상으로, 각 행의 전체 필드를 함께 변화 내림차순으로 정렬하면 첫 원행은 무엇인가요? 현재 첫 위치와 키를 구별하세요.
Source row 42 has change 0 and 168 has 2.5 FTE. Restrict attention to these two rows only and sort all fields of each row together by decreasing change. Distinguish first position from source key.
풀이와 확인할 이유Solution and explanation
이 두 행 중 원행 168이 먼저입니다. 현재 첫 위치는 언어에 따라 Python 0/R 1이지만 원행 키는 168입니다. 현재 순번을 새 열로 만들 수 있으나 출처 키를 덮어쓰지 않습니다.
Among these two rows, source row 168 comes first. Its display position may be Python 0/R 1, but its provenance key stays 168. A new display-rank column must not replace the source key.
48. 고의 오류의 정확한 정의Define the deliberate error precisely
실제 시연은 후 열만 (원코드,원행키)순서로 옮기고 전 열은 원순서에 둡니다. 이를 후 FTE 수치순 정렬이나 새실측이라고 불러도 되나요?
The demonstration reorders only after by (original code, source-row key), leaving before in source order. Is this numerical after-FTE sorting or new observed data?
풀이와 확인할 이유Solution and explanation
둘 다 아닙니다. 명시한 키 순서로 후 열만 재배열한 고의 무효 대응입니다. 실제 관측 짝을 보존하는 전체행 정렬과 구별하며 대안의 정당한 분석으로 제시하지 않습니다.
Neither. It is a deliberately invalid after-only key-order permutation. Distinguish it from legitimate whole-record sorting; it is not an observed alternative analysis.
49. 평균 보존의 증명Prove preservation of the mean
n≥1인 전값 x1,…,xn과후값 y1,…,yn을 두고 순열π로 후값만 바꿉니다. 평균 변화가 유지됨을 증명하세요.
For n≥1 before values xi and after values yi, permute after byπ. Prove the mean change is preserved.
풀이와 확인할 이유Solution and explanation
순열은 합을 보존하므로 Σyπ(i)=Σyi입니다. 따라서 n분의Σ(yπ(i)−xi)는 n분의(Σyi−Σxi)이며 올바른 평균 변화와 같습니다. 이는 합의 항등식이며 관측 대응을 정당화하지 않습니다.
A permutation preserves the sum: Σyπ(i)=Σyi. Hence Σ(yπ(i)−xi)/n=(Σyi−Σxi)/n, the original mean change. This algebra does not validate observed correspondence.
50. 변화 분산이 달라지는 이유Why the change variance differs
같은 분모의 기술분산으로 Var(Y−X)를 전·후 분산과 공분산으로 쓰세요. 후열 순열이 무엇을 바꾸는지 설명하세요.
Using a common descriptive denominator, express Var (Y−X). Explain what an after-only permutation can change.
풀이와 확인할 이유Solution and explanation
Var(Y−X)=Var(Y)+Var(X)−2Cov(X,Y)입니다. 후열의 주변 값·평균·분산은 보존되어도 X와Y의 대응이 바뀌면 공분산이 달라져 변화 분산이 달라질 수 있습니다. 분모n−1에서도n≥2이면 같은 형태입니다.
Var (Y−X)=Var (Y)+Var (X)−2 Cov (X, Y). A permutation preserves each marginal variance but can change paired covariance and therefore change variance. The same form holds for n−1 statistics when n≥2.
51. 같은 실제 평균과 다른 분산Actual equal means, unequal variances
384짝의 올바른 짝과 고의 오류의 평균은 모두 −541/7680 FTE이고 분산은 4788802103/58828800과 11332726583/58828800 FTE²입니다. 차이와 방향을 계산하세요.
For 384 pairs both means equal−541/7680 FTE; variances are 4788802103/58828800 and 11332726583/58828800 FTE². Find their difference and sign.
풀이와 확인할 이유Solution and explanation
둘째에서 첫째를 빼면 6543924480/58828800=1704147/15320, 약 111.2367493 FTE²로 양수입니다. 평균만 같고 개별 대응은 다릅니다. 이 차이를 새로운 관측 불확실성 추정으로 쓰지 않습니다.
The second minus first is 6543924480/58828800=1704147/15320, about 111.2367493 FTE², which is positive. Equal means conceal changed correspondence. This demonstration is not a new observed uncertainty estimate.
52. 해시 충돌이 원리상 가능한 이유Why collisions are possible in principle
SHA-256 출력은 256비트입니다. 허용 입력 중 길이가 33바이트인 모든 바이트열만 비교해도, 왜 모든 서로 다른 입력의 해시가 반드시 다르다고 할 수 없나요?
SHA-256 has 256-bit outputs. Considering only all allowed 33-byte input strings, why can it not assign every different input a different output?
풀이와 확인할 이유Solution and explanation
33바이트는 264비트여서 입력은 2의 264승 개, 출력은 2의 256승 개입니다. 입력이 더 많으므로 비둘기집 원리에 따라 같은 출력을 갖는 서로 다른 입력이 존재합니다. 원하는 충돌을 실무에서 쉽게 찾을 수 있다는 결론은 아닙니다. 무한 입력이라는 전제도 필요하지 않습니다.
There are 2^264 possible 33-byte inputs but only 2^256 outputs. The finite pigeonhole principle implies collisions exist. This does not mean finding a desired collision is practical; no premise of infinitely many allowed inputs is needed.
53. 같은 잘못을 재현한다Reproducing the same mistake
잘못된 후 열 순열 코드와 입력 해시를 모두 보관했고 같은 분산을 세 번 재현했습니다. 관측 짝의 타당성에 어떤 근거가 추가되었나요?
An invalid after-only pairing and its input/code hashes reproduce the same variance three times. What has been established?
풀이와 확인할 이유Solution and explanation
선언한 잘못된 계산이 반복된다는 근거는 생겼지만 관측 짝의 타당성은 생기지 않습니다. 원행 키로 전후 대응을 확인하고 오류를 고친 뒤 새 버전·새 실행을 남겨야 합니다.
Repeatability of that computation, not validity of observed pairing. Verify source-key correspondence, correct the error and retain a new version and execution record.
54. 경고를 기록하는 설명서A manifest with warnings
실제 R 실행은 문자 설정 시작 경고가 있었지만 종료 상태 0이고 3613/3010/603과 평균이 맞았습니다. 결과 보고에서 경고를 삭제하거나 계산 실패로 바꿔야 하나요?
An actual R run has locale startup warnings, exit 0 and correct 3613/3010/603 counts/mean. Should warnings be deleted or the run relabeled failed?
풀이와 확인할 이유Solution and explanation
둘 다 필요하지 않습니다. 실제 경고·종료 상태·검사 통과를 구분해 보존하고 무엇을 점검했는지 설명합니다. 같은 경고가 모든 환경에서 무해하다는 일반화도 하지 않습니다.
Neither. Preserve warnings, exit status and passed checks separately and explain what was verified. Do not generalize that the same warning is harmless in every environment.
55. 코드·출력·인과Code, output and causality
384개 완전짝의 평균 변화를 새 프로세스로 재현했습니다. 정책 효과를 식별했다고 말할 수 있나요?
A fresh process reproduces the mean change of 384 complete store pairs. Has a policy effect been identified?
풀이와 확인할 이유Solution and explanation
아닙니다. 관측 완전짝의 기술 평균 재현입니다. 정책의 반사실 비교·설계·혼란 통제 가정은 별도이며 파일 관리나 새 실행으로 자동 충족되지 않습니다.
No. This reproduces a descriptive observed-pair mean. Counterfactual comparisons, design and confounding assumptions are separate; file organization and fresh execution do not supply them.
56. 기록되지 않은 외부 상태Unrecorded external state
코드와 CSV는 같지만 프로그램이 현재 날짜나 네트워크 응답도 읽습니다. 두 해시만으로 출력 동일성을 보장할 수 있나요?
Code and CSV match, but a program also reads the current date or a network response. Do those two hashes guarantee matching output?
풀이와 확인할 이유Solution and explanation
그렇지 않습니다. 외부 상태가 추가 입력입니다. 필요한 시점·응답 사본·버전·실패 정책을 기록하거나 계산에서 명시적으로 분리해야 합니다. 이 장의 고정 예제는 그런 임의 네트워크 실행을 하지 않습니다.
No. External state adds inputs. Record relevant timing, response snapshots, versions and failure policy, or separate those operations. This chapter’s fixed examples do not perform arbitrary network execution.
57. 파일 크기·행 수만으로 충분할까Are size and row count enough?
두 CSV가 같은 바이트 수와 행 수를 가집니다. 한 열을 다른 열로 바꾸거나 값 4를 5로 바꾸는 오류를 항상 잡나요?
Two CSVs share byte size and row count. Do those checks catch every wrong-column selection or change from 4 to 5?
풀이와 확인할 이유Solution and explanation
잡지 못합니다. 크기와 행 수는 제한된 검사입니다. 열 이름·자료형·단위·키·가용 분모·내용 해시나 명시한 수치 검사를 함께 사용합니다. 같은 크기와 같은 행 수는 내용 동일성의 충분조건이 아닙니다.
No. Check headers, types, units, keys, valid counts and content hashes or declared numerical invariants. Equal size and count are not sufficient for content equality.
58. 새 결과의 계보Lineage of a generated result
원 CSV를 보존하고 작업 사본을 정렬한 뒤 평균을 출력했습니다. 동료가 결과의 계보를 추적하도록 무엇을 연결하겠나요?
You preserve a source CSV, sort a working copy and print a mean. What links let a colleague trace its lineage?
풀이와 확인할 이유Solution and explanation
원 CSV 식별값→작업 사본 변환 규칙과 해시→코드 버전·해시→실행 인자·환경→결과와 검사를 연결합니다. 정렬이 전체 행인지, 결측 행을 보존했는지도 적습니다. 계보가 해석 타당성의 모든 가정을 대신하지는 않습니다.
Connect source identity, transformation rule/working-copy hash, code version/hash, arguments/environment and result/checks. State whole-row sorting and missing-row preservation. Lineage does not replace substantive assumptions.
59. 한 명령 재현 계획A one-command rerun plan
실제 사람 파일 3613행·가용 3010개·미관측 603개를 사용해 한 언어로 재실행할 계획을 쓰세요. 실패 조건과 주장 범위를 포함하세요.
Plan a one-language rerun on the actual 3613-row person file with 3010 available and 603 missing logs. Include failure and claim scope.
풀이와 확인할 이유Solution and explanation
출력 폴더를 기준으로 summary.py 또는 summary.R에 --input 실제 CSV와 --expect-total 3613을 전달합니다. 입력 해시·버전·코드 해시를 확인하고 출력 3613/3010/603과 평균 분수를 대조합니다. 파일 부재·행 수 불일치는 실패로 남깁니다. 가용 로그 기술 평균의 재현이며 미관측 평균·인과·Jupyter 실행을 인증하지 않습니다.
From the output directory, invoke summary.py or summary.R with the actual --input CSV and --expect-total 3613. Check input/code hashes and runtime, then compare 3613/3010/603 and the mean. Retain absent-input/count failures. This reproduces an available-log description, not missing-group means, causality or Jupyter execution.
60. 마지막 감사: 주장마다 근거를 고른다Final audit: choose evidence for each claim
네 주장 ①바이트 같음 ②관측 짝 같음 ③실제 실행함 ④정책 인과효과에 대해 필요한 근거를 구별하세요. 해시 하나로 모두 충분한가요?
Distinguish evidence for (1) byte identity, (2) observed pairing, (3) actual execution, (4) causal policy effect. Does one hash suffice?
풀이와 확인할 이유Solution and explanation
①동일 절차의 바이트 해시·필요시 직접 비교 ②원행 키와 필드 대응 검사 ③명령·실제 프로세스 출력·종료·환경 기록 ④적절한 설계와 식별 가정이 필요합니다. 서로 보완하지만 대체하지 못합니다. 이 교재의 브라우저 선택은 보관 증거를 보여 주며 새 언어 프로세스를 실행하지 않습니다.
Use (1) consistent byte hashes or direct comparison, (2) source-key/field correspondence, (3) actual command/process/output/exit/environment records, and (4) appropriate design and identification assumptions. These support different claims. Browser selection displays retained evidence without starting a new language process.
자료별 확보일·원행 식별·단위·이용 조건은 출처 기록을 확인하세요. 학습 사본은 제공처의 현재 최신 자료와 다를 수 있습니다.Consult each source record for retrieval dates, row identifiers, units and terms. Teaching copies can differ from current provider releases.