자료 계약·검사·재현 환경Data contracts, tests and reproducible environments
작은 기대 결과에서 원행 보존·오류 검사·실행 환경까지From small expected results to retained rows, error tests and recorded environments
실습 6종 · 풀이 포함 연습문제 60개6 labs · 60 exercises with solutions
기초Foundations
1. 세 행에서 먼저 확인할 약속을 적는다1. Write the promises to check on three rows
작은 기록표에 값이 1, 빈칸, 3으로 적혀 있다고 합시다. 빈칸은 측정한 0이 아니라 아직 값이 없는 상태입니다. 관측한 두 값의 합은 4이고, 그 두 값을 평균하면 4/2=2입니다. 전체 기록은 세 행이라는 사실도 그대로 남습니다.
설명용 세 행 · 어느 행도 삭제하지 않음
원행 키
업무 코드
값
1
A
1
2
B
결측
3
B
3
이 표에서 “원행 키가 겹치지 않는다”는 약속은 맞습니다. “업무 코드가 겹치지 않는다”는 약속은 B가 두 번 있어 맞지 않습니다. 두 번째 약속을 통과시키려고 B의 한 행을 지우면 우리가 받은 기록과 평균을 바꿀 수 있습니다.
이번 장은 먼저 무엇을 확인할지 문장으로 쓰고, 작은 계산으로 기대 결과를 정한 뒤, 프로그램으로 같은 검사를 반복합니다. 이런 명시적인 자료의 약속을 자료 계약이라고 부르겠습니다. 계약이 실패하면 자료를 바꾸기 전에 그 약속을 정한 이유부터 다시 봅니다.
Suppose a small record table contains one, a missing value and three. Missing is not an observed zero. The two observed values sum to four and have mean 4/2=2, while the complete table still contains three rows.
Three toy rows · none removed
Source-row key
Business code
Value
1
A
1
2
B
Missing
3
B
3
The promise “source-row keys are unique” holds. The promise “business codes are unique” fails because B occurs twice. Deleting a B row just to pass that second promise can change the retained records and their mean.
First state what to check, work out a small expected result, then repeat the check in a program. Call an explicit promise about data a data contract. When it fails, revisit the reason for the promise before changing the records.
기초Foundations
2. 계약의 문장과 계약을 검사하는 코드는 다르다2. A contract statement differs from the code checking it
“세 행을 보존한다”는 문장에는 비교할 개수 3이 있습니다. “숫자는 음수가 아니어야 한다”에는 허용 범위가 있습니다. “빈칸을 허용한다”에는 결측을 값 0과 다르게 취급한다는 선택이 있습니다. 먼저 이 선택을 독자가 읽을 수 있게 적습니다.
검사 코드는 그 약속이 현재 입력에서 참인지 계산합니다. 올바른 코드로 잘못 정한 약속을 검사할 수도 있습니다. 원 코드가 반복될 수 있는 자료에 “모든 원 코드가 고유해야 한다”고 쓰면, 프로그램이 정확히 거절해도 원자료가 잘못되었다는 뜻은 아닙니다.
반대로 코드 자체의 실수도 가능합니다. 가용 두 값을 더한 뒤 전체 세 행으로 나누면 4/3입니다. 프로그램이 실행을 마쳤다는 사실만으로 2를 계산했다고 말할 수는 없습니다. 약속, 검사 구현, 현재 입력의 검사 결과를 세 칸으로 남깁니다.
“Retain three rows” specifies an expected count. “Numbers must be nonnegative” specifies a range. “Allow missing values” distinguishes missingness from observed zero. State these choices so a reader can inspect them.
Checking code computes whether a promise holds for the supplied input. Correct code can check an unjustified promise. If original codes may repeat, correctly rejecting a uniqueness claim does not establish an error in the source.
The implementation can also be wrong: summing two observed values but dividing by all three rows gives 4/3. Completing execution does not mean the intended mean two was calculated. Keep the promise, its implementation and its observed result in separate fields.
기초Foundations
3. 값·행·표·계산 경로의 검사를 나눈다3. Distinguish checks on a value, row, table and procedure
값 하나가 숫자인지 확인하는 검사와 표 전체의 원행 수가 3인지 확인하는 검사는 다른 범위를 봅니다. 각각 맞아도 다른 조건이 틀릴 수 있습니다. 세 숫자 1·2·3은 모두 음수가 아니지만, 그 표가 필요한 네 행을 전부 담았는지는 값 범위 검사만으로 알 수 없습니다.
서로 대신할 수 없는 네 가지 검사
범위
작은 검사
확인하는 것
값
0≤값≤3
선언한 허용 범위
행
원행 키와 값 칸이 있음
행의 필요한 필드
표
원행 키가 고유함
이 사본 안의 키 반복
계산
1·결측·3의 가용평균은 2
지정한 계산의 한 사례
여러 약속을 모두 요구할 때는 검사 결과를 하나씩 남기고 마지막에 모두 참인지 묶습니다. 전체 통과라는 한 단어만 남기면 어느 약속이 빠졌는지 읽기 어렵습니다.
이 장의 도구는 사실 여부를 자동으로 매기는 점수표가 아닙니다. 관측한 값과 선언한 규칙 사이의 관계를 보여 줍니다. 단위, 어떤 행을 필요로 하는지, 원 코드의 의미는 자료 문서와 질문에서 정합니다.
Checking one value’s numeric kind differs from checking that the whole table retains three rows. One condition can hold while another fails. Values one, two and three are nonnegative, but that alone does not show whether a required fourth row is absent.
Four checks with different scopes
Scope
Small check
What it checks
Value
0≤value≤3
Declared permitted range
Row
Key and value fields present
Required row fields
Table
Source-row keys unique
Repeated keys in this copy
Calculation
Available mean of 1/missing/3 equals 2
One case of the specified procedure
When several promises are required, retain each result before combining them with “all.” A single pass label obscures which promises were actually checked.
These tools compare observed data with declared rules. They do not assign automatic truth scores. Units, required rows and the meaning of an original code come from the source documentation and the question.
기초Foundations
4. 결측·관측한 0·잘못 읽은 글자를 구별한다4. Separate missing, observed zero and invalid text
설명용 입력을 ["0", null, "bad", "-1"]로 둡니다. 첫 칸은 숫자 0을 원문으로 적은 문자열이고, 둘째 칸은 결측입니다. 셋째는 이 도구의 숫자 문법으로 읽을 수 없고, 넷째는 읽을 수 있는 음수입니다.
“숫자가 음수가 아니어야 한다”는 약속에서는 넷째가 범위를 벗어납니다. 셋째는 그보다 앞서 숫자로 읽기부터 실패합니다. 두 실패를 모두 “빈칸”으로 바꾸면 원래 있던 문제를 숨깁니다.
실습 A는 이 네 상태와 원위치를 보존합니다. 잘못된 숫자 글자가 있으면 전체 수치 합·평균을 미정의로 두어, 그 행만 몰래 빼고 더 작은 분모의 평균을 만들지 않습니다. 읽을 수 있는 범위 밖 숫자는 원값 그대로 요약하고 범위 실패를 따로 표시합니다.
Take toy input ["0", null, "bad", "-1"]. The first field contains numeric source text zero, the second is missing, the third is not valid numeric text for this tool, and the fourth is a readable negative number.
Under a nonnegative-value promise, the fourth field fails the range rule. The third fails numeric parsing first. Replacing both failures with missing values would conceal the original distinction.
Lab A preserves these states and their source positions. Invalid numeric text leaves the full numeric sum and mean undefined, rather than silently removing that row and using a smaller denominator. Readable out-of-range numbers remain in the numeric summary, with a separate failed range flag.
기초Foundations
5. 전체 세 행과 가용 두 값을 각각 센다5. Count all three rows and two available values separately
다시 1·결측·3으로 돌아갑니다. 전체 N=3, 가용 n=2, 가용 합 S=4입니다. 가용평균은 S/n=2입니다. 결측을 0으로 채운 별도 표를 만들면 세 값 1·0·3의 평균 S/N=4/3이 됩니다.
두 계산은 서로 다른 질문의 답입니다. 관측하지 않은 칸을 0으로 채운 계산을 원자료의 가용평균이라고 부르지 않습니다. 실제 임금 자료에서도 원임금과 원 로그임금은 결측 수가 달라 각각의 가용분모를 셉니다.
가용값이 하나도 없으면 가용 합은 빈 합 0으로 둘 수 있지만 평균의 분모도 0입니다. 이 경우 평균은 미정의입니다. 합 0을 평균 0으로 바꾸지 않습니다. 행별 결측을 허용하는 계약은 통과하면서 평균은 미정의일 수 있습니다.
Return to one, missing and three. Total rows N=3, available values n=2 and available sum S=4 give mean S/n=2. A separate zero-filled table one/zero/three instead has mean S/N=4/3.
These answer different questions. A zero-filled mean is not the original available-value mean. Actual raw-wage and source-log fields also have different missing counts and must use their own denominators.
With no available values, the empty sum can be zero while the mean denominator is also zero. The mean is undefined. Allowing missing fields can produce a passing row contract and an undefined mean at the same time.
기초Foundations
6. 양끝 포함과 결측 허용을 직접 정한다6. Declare inclusive bounds and the missing-value rule
허용 범위를 0 이상 3 이하로 정하면 값 0과 3은 통과하고 −1과 4는 실패합니다. 값이 정확히 경계에 있는 경우를 작은 검사에 넣으면 양끝 포함 여부를 분명히 할 수 있습니다.
빈칸은 0보다 작은 숫자가 아닙니다. “결측을 허용한다”는 별도 규칙이 참이면 빈칸이 허용되고, 거짓이면 결측 금지 실패가 됩니다. 빈칸에 범위 부등식을 적용해 0이나 음수로 판정하지 않습니다.
실습은 정확 십진수·분수 문자열을 받습니다. "1/3"과 "0.333333"은 서로 다른 정확 수입니다. 범위 경계에서 표시 근삿값만 비교해 둘을 같다고 처리하지 않습니다. 실제 원문이 이미 반올림된 값이면 그 원문 범위를 넘는 정밀도를 복원한 것은 아닙니다.
For inclusive bounds zero through three, values zero and three pass; minus one and four fail. Testing values exactly at the boundaries makes endpoint conventions visible.
Missing is not a number below zero. A separate nullable rule determines whether it is allowed. Do not apply the range inequality to a missing field by silently converting it to zero or a negative value.
The lab accepts exact decimal/fraction text. "1/3" and "0.333333" are different exact numbers. Compare their exact values at a boundary rather than treating rounded displays as equal. Reading retained source text does not recover precision lost before that text was published.
기초Foundations
7. 작은 함수의 입력과 출력 약속을 함께 쓴다7. State a small function’s input and output promises
함수를 작은 계산 상자라고 생각합시다. 입력 약속은 “숫자 문자열 또는 결측의 목록을 받는다”입니다. 출력 약속은 “원위치와 결측 표시를 남기고, 유효한 숫자 자료이면 가용 합·평균을 계산한다”입니다.
같은 목록을 다시 넣어도 원목록을 바꾸지 않는 함수는 검사를 이어 붙이기 쉽습니다. 먼저 전체 행 수를 확인하고 다음에 평균을 계산해도, 앞 검사가 뒤 입력의 행을 삭제하지 않았기 때문입니다. 원자료를 고치는 단계가 필요하다면 변경 전후와 이유를 별도 산출물로 둡니다.
검사 실패를 반환하는 것과 프로그램이 예외를 내는 것도 구별합니다. 값 −1이 선언한 0 이상 규칙을 어긴 것은 데이터와 약속의 불일치입니다. 상한 0·하한 3처럼 규칙 자체를 거꾸로 적은 경우는 검사 설정을 고쳐야 합니다.
Think of a function as a small calculation box. Its input promise can be “a list of numeric text or missing values.” Its output promise can be “retain source positions and missing flags, then compute the available sum/mean when numeric parsing succeeds.”
A function that leaves its input unchanged is easier to compose with other checks. A row-count check can precede a mean calculation without deleting the later calculation’s rows. If a transformation is needed, retain its before/after state and reason separately.
Returning a failed condition differs from raising a software exception. Value minus one violates a declared nonnegative range. A lower bound three above upper bound zero instead makes the rule configuration invalid.
기초Foundations
8. 실습 A · 원행과 실패 이유를 함께 읽는다8. Lab A · Read original positions and failure reasons
입력 ["1", null, "3"]에서 결측을 허용하고 범위를 0–3으로 둡니다. 전체 3·가용 2·합 4·평균 2를 확인하세요. 결측 허용을 끄면 그 행의 계약 결과만 바뀌며 원래 값과 세 행은 남습니다.
그다음 "bad"를 넣어 숫자 읽기 실패와 미정의 평균을 봅니다. "-1"로 바꾸면 읽을 수 있는 범위 밖 숫자가 됩니다. 잘못된 설정에서는 앞 성공 표를 지우고 오류를 표시합니다.
아래 고정 실행은 같은 작은 예제를 별도 Python/R 새 프로세스에서 실행한 기록입니다. 위 입력을 Python/R로 새로 실행한 것처럼 표시하지 않습니다. 실제 프로그램·입력·버전·표시 설정은 기록과 함께 확인합니다.
With ["1", null, "3"], allow missingness and set bounds zero through three. Verify total three, available two, sum four and mean two. Turning off nullable changes that row’s contract result while preserving the original values and all three positions.
Insert "bad" to see numeric failure and an undefined mean. Replacing it with "-1" gives a readable out-of-range value. Invalid rule configuration clears the previous successful table and displays an error.
The fixed executions below show separate fresh Python/R runs of small examples. The live inputs are not represented as newly executed Python/R programs. Read their actual programs, inputs, versions and display settings alongside the records.
기초Foundations
9. 칸이 없는 행과 빈칸을 가진 행을 나눈다9. Separate an absent field from a present missing field
두 기록 {"row":1,"value":null}과 {"row":2}를 나란히 봅시다. 첫 기록에는 값 칸이 있고 그 내용이 결측입니다. 둘째 기록에는 값이라는 칸 자체가 없습니다. “모든 행에 값 칸이 있어야 하며 그 칸의 결측은 허용한다”는 약속에서는 첫 행은 통과하고 둘째 행은 실패합니다.
숫자 0은 세 번째 상태입니다. {"row":3,"value":"0"}에는 값 칸과 관측한 숫자 원문이 모두 있습니다. 세 상태를 한 가지 빈 문자열로 바꾸면, 어떤 단계에서 필드가 사라졌는지 뒤에서 추적하기 어렵습니다.
이번 장의 값 목록 실습 A는 이미 존재하는 목록 위치의 숫자·결측을 봅니다. 키 실습 B는 기록의 필드 존재도 별도로 봅니다. 같은 화면의 결측이라는 말이라도 어느 입력 구조의 어느 칸인지 먼저 확인하세요.
Compare {"row":1,"value":null} with {"row":2}. The first record has a value field whose content is missing. The second lacks that field. Under “every row must have a value field, but its content may be missing,” the first passes and the second fails.
Observed zero is a third state. {"row":3,"value":"0"} has both the field and numeric source text. Collapsing all three states to an empty string obscures where a field disappeared.
Lab A checks numeric/missing states at existing list positions. Lab B separately checks field presence in records. First locate the field and input structure to which a missingness statement refers.
기초Foundations
10. 숫자 1·문자 1·참 값을 같은 키로 합치지 않는다10. Keep numeric one, text one and true as distinct keys
세 표식을 1, "1", true로 써 봅시다. 사람이 보기에는 앞의 두 표식이 비슷하지만 첫째는 숫자, 둘째는 문자열, 셋째는 논리값입니다. 원자료가 어느 형식을 약속했는지에 따라 같은 표식으로 읽을 근거가 달라집니다.
실습 B는 타입을 함께 보존한 키를 만듭니다. 예를 들어 숫자 1은 ["number",1], 문자 1은 ["string","1"]입니다. 이 명시적 규칙에서는 둘이 다릅니다. 모든 키를 문자열로 바꾼 뒤 고유 개수만 세는 방식과 구별됩니다.
이 도구가 키로 받는 숫자는 안전하게 표현되는 정수입니다. 너무 큰 정수 원문을 이미 반올림한 숫자로 바꿔 넣으면 서로 다른 원문이 합쳐질 수 있습니다. 그런 원키는 문자열로 보존하고, 숫자로 읽는 별도 분석이 필요한지 따로 정합니다.
Write three markers: 1, "1" and true. They denote a number, a string and a Boolean. Whether two source markers should be equated depends on their declared representation.
Lab B retains the type alongside the value. Numeric one becomes ["number",1]; text one becomes ["string","1"]. Under this explicit rule they differ. This is distinct from converting every key to text before counting unique values.
Numeric key inputs are safe integers. Converting a much larger source integer to an already rounded number can merge distinct originals. Retain such keys as strings, then decide separately whether a numeric analysis is appropriate.
기초Foundations
11. 두 칸의 조합은 구분자 하나보다 안전하게 표현한다11. Represent a two-field key as a tuple
설명용 두 행의 키 성분이 각각 ("a|b","c")와 ("a","b|c")라고 합시다. 세로줄을 사이에 붙여 한 문자열로 만들면 둘 다 "a|b|c"가 됩니다. 원래 다른 두 조합이 같은 문자열로 합쳐진 것입니다.
각 성분을 별도 칸에 둔 순서 있는 목록으로 표현하면 첫 조합은 첫 칸에 "a|b"를, 둘째 조합은 첫 칸에 "a"를 가집니다. 타입을 덧붙인 중첩 목록을 올바르게 직렬화하면 따옴표·구분자도 성분 내용으로 남습니다.
국가 자료의 한 관측은 국가·지표·연도의 조합으로 고릅니다. 국가 코드 하나만 사용하면 같은 나라의 여섯 연도가 겹치며, 연도 하나만 사용하면 여러 나라의 같은 연도를 구별하지 못합니다. 질문에 필요한 모든 키 성분을 먼저 적습니다.
Suppose two toy keys are ("a|b","c") and ("a","b|c"). Joining components with a vertical bar produces "a|b|c" in both cases. Different original tuples have collided.
An ordered list keeps the components separate: the first tuple starts with "a|b" and the second with "a". Correct serialization of a typed nested list preserves quotes and delimiters as component content.
An annual country observation is selected by country, indicator and year together. Country alone repeats across six years; year alone repeats across countries. State every component required by the question before checking uniqueness.
기초Foundations
12. 반복된 업무 코드에서 원행을 먼저 보존한다12. Retain source rows when a business code repeats
첫 표의 업무 코드 A·B·B에는 서로 다른 코드가 두 개 있지만 행은 세 개입니다. B 두 행의 값이 결측과 3이라면 두 행이 같은 기록이라는 설명도 아직 없습니다. 코드 반복만으로 어느 하나를 버릴 수 없습니다.
고유 원행 번호 1·2·3은 이 사본의 위치를 다시 찾는 데 도움이 됩니다. 사람이 평생 쓰는 신분 번호나 점포의 영구 식별 번호가 자동으로 생긴 것은 아닙니다. 원행 번호와 업무 코드를 다른 열로 남겨야 반복을 검토할 때 둘을 함께 볼 수 있습니다.
실제 점포 자료도 410개 원행과 409개 원 코드입니다. 원 코드 407의 두 기록은 원행 42와 168에 있으며 주·체인·변화량이 다릅니다. 뒤에서 이 두 행을 실제 표로 확인하고, 임의 삭제가 평균을 어떻게 바꾸는지 별도 비교하겠습니다.
Business codes A/B/B contain two distinct codes but three rows. If the B records contain missing and three, equality of their code has not established that they are the same record. It does not select a row to discard.
Source positions one/two/three help locate rows in this copy. They do not automatically become lifelong person identifiers or permanent store identifiers. Keep source position and business code in separate columns so a repeated code can be inspected in context.
The actual store file has 410 source rows and 409 original codes. Code 407 occurs at source rows 42 and 168, with different state, chain and change values. Later, inspect both records and compare the effect of arbitrary deletion separately.
기초Foundations
13. 키의 결측 허용과 필드 부재를 따로 판정한다13. Check null-key permission separately from absent fields
키 필드가 id일 때 {"id":null}은 명시적 결측 키입니다. {}에는 키 필드가 없습니다. 실습 B의 기본값은 결측 키도 허용하지 않으므로 두 행 모두 실패하지만 실패 이유가 다릅니다.
결측 키 허용을 켜면 첫 행의 명시적 결측은 유효한 키 성분이 될 수 있습니다. 같은 명시적 결측 조합이 두 번 나오면 그 규칙 아래서는 키 반복으로 셉니다. 필드 자체가 없는 둘째 행은 여전히 부재 실패입니다.
유효한 키만 모았을 때 고유하다는 결과와 모든 행의 키가 유효하고 고유하다는 결과를 구별합니다. 유효 키 한 개와 부재 키 두 개가 있으면 앞 결과는 참일 수 있지만 전체 계약은 실패합니다. 실패 행은 원위치와 함께 남습니다.
For key field id, {"id":null} has an explicit null key; {} lacks the field. With null keys disallowed by default, both fail for different reasons.
Allowing null keys can make the first record’s explicit null a valid component. Two identical null tuples then count as repeats under that rule. The absent field remains invalid.
“Unique among valid keys” differs from “every row has a valid, unique key.” One valid key and two absent keys can satisfy the first statement while failing the full contract. Retain the failing rows and their original positions.
기초Foundations
14. 빈 목록에서 모두 참과 계산 가능을 구별한다14. Separate vacuous truth from an available calculation
검사할 행이 하나도 없다고 합시다. “이 목록에 같은 키가 두 번 나오는가?”에는 아니라고 답할 수 있습니다. 그러나 “필요한 여섯 관측을 모두 받았는가?”에는 행 수 0과 기대 수 6을 비교해야 합니다. 고유성만으로 완전성을 대신하지 않습니다.
논리에서 빈 조건 목록의 “모두 참”은 참으로 정할 수 있습니다. 반례가 하나도 없다는 뜻이며 실제 조건을 많이 확인했다는 뜻은 아닙니다. 실습 C에 기대 조건을 하나도 주지 않으면 이 빈 결합 결과를 직접 표시합니다.
숫자 계산도 별도입니다. 빈 숫자 목록의 합은 0, 평균은 미정의입니다. 키 고유성 참·조건 결합 참·평균 미정의가 동시에 나와도 모순이 아닙니다. 각각이 무엇을 물었는지 읽으면 세 답이 자연스럽게 이어집니다.
Suppose no rows were received. No key appears twice, but receiving all six required observations still requires comparing actual count zero with expected count six. Uniqueness does not substitute for completeness.
In logic, “all” over an empty condition list can be true: there is no counterexample. It does not mean many substantive conditions were checked. Lab C explicitly labels this empty conjunction when no expectations are supplied.
Numeric availability is separate. An empty numeric list can have sum zero and an undefined mean. Unique keys, a true empty conjunction and an undefined mean can coexist because they answer different questions.
기초Foundations
15. 실습 B · 고유 원행과 반복 코드의 차이를 바꿔 본다15. Lab B · Compare unique row keys with repeated codes
A·B·B의 세 기록에서 ["source_row"]와 ["code"]를 번갈아 키 필드로 선택하세요. 같은 세 행을 보존하면서 고유 여부가 달라집니다. 중복 그룹을 열어 원위치 1과 2가 함께 남는지 확인합니다. 화면의 원위치는 0부터 시작하므로 원행 번호 2·3과 표시 방식이 다릅니다.
그다음 숫자 1·문자 1·참 값과 구분자를 가진 두 조합을 넣어 봅니다. 타입과 성분 경계를 남기는 이유를 실제 고유 개수로 확인하세요. 키 필드 이름을 잘못 쓰면 존재하지 않는 칸을 자동으로 만들어 주지 않습니다.
아래 Python/R 고정 실행에는 원행 키·업무 코드·타입을 보존한 조합 예제가 따로 있습니다. 언어별 직렬화의 숫자 표기 방식은 다를 수 있지만, 각 성분의 타입·값과 조합 구별은 별도로 비교합니다.
For three A/B/B records, switch key fields between ["source_row"] and ["code"]. The same retained rows yield different uniqueness results. Inspect the duplicate group: zero-based positions one and two correspond to source-row labels two and three.
Try numeric one, text one, true and the two tuples containing delimiters. Their distinct counts show why types and component boundaries matter. A misspelled key field is not silently created.
Separate fixed Python/R executions cover source-row keys, business codes and typed composite tuples. Numeric spelling inside serialized output can differ by language; component types, values and distinctions are compared separately.
기초Foundations
16. 개수·합·평균을 연결해 손으로 점검한다16. Connect counts, sum and mean by hand
1·결측·3에서 원행 수 3, 가용 수 2, 합 4, 평균 2라는 네 결과를 적습니다. 가용 수와 평균을 곱하면 2×2=4로 합을 되찾습니다. 이 관계를 검사하면 분모나 출력 열을 잘못 붙인 실수를 발견하는 데 도움이 됩니다.
그러나 관계 하나만 통과하는 잘못된 결과도 만들 수 있습니다. 프로그램이 합 6·가용 수 3·평균 2를 함께 내놓으면 3×2=6은 맞지만 원자료의 가용 수와 합은 틀렸습니다. 입력에서 직접 세는 검사와 출력끼리의 관계 검사를 함께 둡니다.
일반적으로 모든 비결측 값이 유효한 숫자이고 가용 수 n≥1이면 S=n×평균입니다. 가용 수가 0일 때에는 평균을 계산하지 않으므로 이 식을 미정의 값에 적용해 통과시키지 않습니다.
For one/missing/three, record total rows three, available count two, sum four and mean two. Multiplying available count by mean gives 2×2=4. This relation can expose a misplaced denominator or output column.
A wrong result can still satisfy one relation. Sum six, available count three and mean two obey 3×2=6, while the source count and sum are wrong. Combine direct checks against the input with relations among outputs.
When every nonmissing field is valid numeric text and available count n≥1, S=n×mean. With n=0, the mean is undefined; do not pass the identity by assigning a value to that undefined mean.
기초Foundations
17. 기대 결과를 먼저 정하고 현재 결과와 비교한다17. Specify the expected result before comparing the observed one
“가용 수 2와 평균 2를 기대한다”고 적은 뒤 계산 결과와 비교합시다. 네 조건 중 하나만 실패해도 전체 결합은 실패입니다. 어떤 조건이 기대와 달랐는지 표에서 따로 읽을 수 있어야 합니다.
실습 C에서 기대 원행 수를 3에서 4로 바꾸면 자료를 그대로 둔 채 원행 수 조건만 실패합니다. 실패를 없애려고 가짜 행을 덧붙이는 것은 다른 작업입니다. 기대 수 4가 맞는 근거가 있는지, 수집 단계에서 행이 누락되었는지부터 확인합니다.
기대값도 사람이 정한 입력입니다. 정답과 같은 이름을 붙였다는 이유로 자동으로 옳아지지 않습니다. 작은 사례를 손으로 계산하고 자료 문서의 범위를 읽어 기대값의 근거를 남기는 것이 검사 작성의 시작입니다.
State “expect available count two and mean two,” then compare the observed result. One failed condition makes the conjunction fail, while the individual condition table explains which expectation differed.
In Lab C, changing expected row count from three to four fails only that condition while retaining the data. Adding an invented row to remove the failure is a different operation. First ask whether four is justified or whether collection omitted a required row.
An expectation is also a supplied input. Calling it expected does not make it correct. Work out small cases and retain the source-document basis for expectations.
기초Foundations
18. 정확 비교와 표시 반올림을 각각 읽는다18. Read exact comparison separately from rounded display
정확한 1/3과 소수점 여섯 자리 0.333333의 차이는 1/3000000입니다. 둘 다 화면에서 0.3333으로 보일 수 있지만 정확 경계 1/3 이상이라는 규칙에서는 결과가 다릅니다. 첫 값은 통과하고 둘째는 실패합니다.
31−1000000333333=300000011000000333333<31
실습의 정확 분수 필드는 입력한 유한 십진수·분수 문자열의 값을 나타냅니다. 화면의 짧은 근삿값은 읽기 위한 표시입니다. 아주 작은 양수가 표시에서 0이 되거나 큰 유한수가 표시 범위를 넘을 때도, 정확 비교 결과와 표시 상태를 따로 둡니다.
실제 자료의 원문 숫자 자체가 이미 반올림되어 있으면 정확 문자열 계산도 그 공표값에 대한 계산입니다. 측정되기 전의 참값이나 공표 전 자릿수를 복원한 것은 아닙니다.
The exact difference between 1/3 and six-decimal 0.333333 is 1/3000000. Both may display as 0.3333, yet they differ under an exact lower bound 1/3: the first passes and the second fails.
31−1000000333333=300000011000000333333<31
An exact-fraction field represents the supplied finite decimal/fraction text. Its shorter approximation is for display. If a tiny positive value displays as zero, or a finite value exceeds the display range, exact comparison and display state remain separate.
When the published source text was already rounded, exact text arithmetic concerns that published value. It does not reconstruct an earlier measurement or unpublished digits.
기초Foundations
19. 근사 계산의 허용 오차를 숫자와 단위로 정한다19. Specify a numerical tolerance with scale and units
두 근사 결과가 100과 100.000001이라고 합시다. 차이는 0.000001입니다. “소수점 아래 여섯 자리쯤”이라는 말보다 절대 오차 한계 0.000002를 직접 적으면 비교가 명확합니다. 값의 단위가 달러라면 이 절대 한계도 달러입니다.
값의 규모가 크게 달라질 때는 상대 항을 함께 둘 수 있습니다. 유한한 비교값 a,b와 비음수 허용치 ε_abs,ε_rel에 대해 아래 규칙을 쓰면 0 근처에는 절대 항이, 큰 값에는 상대 항이 도움을 줍니다. 두 항을 어느 상황에서 정했는지도 기록합니다.
∣a−b∣≤εabs+εrelmax(∣a∣,∣b∣)
이 규칙은 자료의 의미가 같다는 증명이 아닙니다. 달러와 센트, 다른 행 집합, 다른 평균 분모를 큰 허용 오차로 통과시키면 비교 대상부터 달라집니다. 미정의·무한·표시 범위 초과 상태는 먼저 구별하고 유한 근사값 비교에 이 규칙을 적용합니다.
Suppose two approximations are 100 and 100.000001. Their difference is 0.000001. An explicit absolute tolerance 0.000002 is clearer than “roughly six decimal places.” If the values are dollars, that absolute tolerance is also in dollars.
For differing scales, add a relative term. For finite a,b and nonnegative tolerances, the following declared rule uses an absolute term near zero and a scale-dependent term for large values. Record why these tolerances were chosen.
∣a−b∣≤εabs+εrelmax(∣a∣,∣b∣)
Passing this rule does not prove equal meaning. Dollars versus cents, different row sets or different mean denominators cannot be reconciled by an oversized tolerance. Separate undefined, infinite and display-overflow states before applying a finite approximation comparison.
기초Foundations
20. 여러 통과 조건을 묶어도 원자료의 뜻은 별도다20. A conjunction does not establish the meaning of source data
세 행·가용 두 값·합 4·평균 2라는 조건이 모두 맞아도, 값의 단위가 무엇인지는 이 네 계산에서 나오지 않습니다. 원자료가 시간당 센트라면 시간당 달러와 구별하는 문서 읽기가 더 필요합니다.
마찬가지로 원행 키가 고유하다는 것은 이 사본에서 그 키가 겹치지 않았다는 뜻입니다. 다른 날의 같은 사람인지, 같은 점포가 다른 코드로 나타났는지는 별도 정보가 필요합니다. 고유성 검사에 그런 의미까지 붙이지 않습니다.
검사를 더할 때는 “이 새 조건은 어떤 실수를 잡는가?”를 작은 반례로 설명해 보세요. 개수 검사는 누락, 키 검사는 반복, 평균 항등식은 계산 연결을 볼 수 있습니다. 여러 조건의 역할을 설명하면 통과라는 결과도 더 잘 읽힙니다.
All four conditions—three rows, two available values, sum four and mean two—can hold without establishing the measurement unit. If source values are cents per hour, distinguishing them from dollars per hour requires the documentation.
Unique source keys show no repetition of those keys in this copy. Whether two records on different dates describe the same person or store requires other information.
When adding a check, explain the error it detects with a small counterexample. Counts can expose omissions, keys can expose repeated tuples and arithmetic identities can expose disconnected calculations. These distinct roles make a pass result interpretable.
기초Foundations
21. 실습 C · 맞는 기대와 틀린 기대를 비교한다21. Lab C · Compare justified and incorrect expectations
입력 1·결측·3에서 기대 조건 {"sourceCount":3,"availableCount":2,"sum":"4","mean":"2"}를 사용하세요. 각 조건과 전체 결합을 확인한 다음, 기대 원행 수만 4로 바꿉니다. 원행 표가 그대로 남는지 봅니다.
기대 평균을 "4/3"으로 바꾸면 가용평균 계산이 그 기대를 거절합니다. 결측을 0으로 바꿔야 한다는 결론이 아니라, 두 평균의 정의가 다르다는 신호입니다. 빈 기대 객체 {}는 조건을 하나도 검사하지 않은 참 결합으로 표시합니다.
고정 Python/R 실행은 맞는 네 조건과 틀린 원행 수의 예를 따로 남깁니다. 프로그램 종료가 성공이어도 어떤 선언 조건은 실패할 수 있습니다. 실패를 정확히 보고하는 프로그램은 정상적으로 실행될 수 있기 때문입니다.
For one/missing/three, use expectations {"sourceCount":3,"availableCount":2,"sum":"4","mean":"2"}. Inspect each condition and the conjunction, then change only expected source count to four. The original rows remain.
Expected mean "4/3" is rejected by the available-mean calculation. This signals differing definitions, not an instruction to fill missing values with zero. An empty expectation object {} is labeled a true conjunction with no conditions checked.
Separate Python/R records show the correct four expectations and the wrong-count example. A successful process exit can coexist with a failed declared data condition because the program correctly reported that failure.
기초Foundations
22. 테스트 한 개를 입력·기대·관측의 세 칸으로 만든다22. Write one test as input, expectation and observation
평균 함수의 한 테스트를 만듭시다. 입력은 1·결측·3, 기대는 가용평균 2입니다. 관측 결과가 2이면 이 테스트는 통과하고, 4/3이면 실패합니다. 기대를 출력에서 다시 복사해 만들면 같은 실수를 함께 복제할 수 있습니다.
설명용 함수 두 구현을 같은 입력으로 비교
입력
먼저 정한 기대
실제 관측
판정
1·결측·3
2
2
통과
1·결측·3
2
4/3
실패
이렇게 입력과 기대 결과를 묶은 작은 사례를 테스트 케이스라고 부릅니다. 사례를 여러 개 모아 같은 계산 절차에 적용한 것이 테스트 묶음입니다. 전체 결측·빈 목록·잘못된 숫자 글자처럼 서로 다른 경계를 골라 넣습니다.
테스트가 통과했다는 말에는 어떤 구현을 어떤 입력에 적용했고 어떤 기대와 비교했는지가 따라야 합니다. 네 테스트의 통과를 모든 가능한 자료의 정답 보장으로 확대하지 않습니다.
Create one test for a mean function. Input is one/missing/three; expected available mean is two. Observed two passes; observed 4/3 fails. Copying the expectation from the implementation output can reproduce the same mistake.
Two toy implementations on the same input
Input
Expectation fixed first
Observed result
Outcome
1/missing/3
2
2
Pass
1/missing/3
2
4/3
Fail
An input paired with its expected result is a test case. A suite applies several such cases to the same procedure. Include distinct boundaries such as all missing, empty input and invalid numeric text.
A test result needs the implementation, input and expectation. Passing four selected cases does not establish correctness on all possible data.
기초Foundations
23. 세 평균 구현을 작은 사례로 구별한다23. Distinguish three mean implementations on small cases
첫 구현은 유효한 가용값을 모두 더하고 가용 수로 나눕니다. 둘째 구현은 같은 합을 전체 행 수로 나눠 결측을 0처럼 취급합니다. 셋째 구현은 첫 가용값 하나만 반환합니다. 첫 입력 1·결측·3에서는 각각 2,4/3,1입니다.
이 장의 네 선언 테스트에서 구현이 내는 결과
입력
가용평균
0 채움 평균
첫 가용값
1·결측·3
2
4/3
1
결측 한 칸
미정의
0
미정의
빈 목록
미정의
미정의
미정의
bad
예상 숫자 오류
예상 숫자 오류
예상 숫자 오류
첫 구현은 네 기대를 모두 만족합니다. 둘째는 첫 두 입력에서 실패하고, 셋째는 첫 입력에서 실패합니다. 빈 목록 검사 하나만으로는 세 구현을 구별하지 못합니다. 어떤 버그를 드러내는 입력인지 생각하며 사례를 고릅니다.
둘째 계산이 언제나 쓸모없다는 뜻은 아닙니다. 결측을 0으로 대체한 별도 표의 평균이라는 질문에는 답할 수 있습니다. 여기서는 원자료의 가용평균을 약속했기 때문에 그 약속의 테스트에서 실패합니다.
One implementation sums every valid available value and divides by available count. A second divides that sum by all rows, treating missingness as zero. A third returns only the first available value. On one/missing/three they return two, 4/3 and one.
Outputs on the four declared cases
Input
Available mean
Zero-filled mean
First available
1/missing/3
2
4/3
1
One missing field
Undefined
0
Undefined
Empty list
Undefined
Undefined
Undefined
bad
Expected numeric error
Expected numeric error
Expected numeric error
The first passes all four expectations. The second fails the first two; the third fails the first. The empty-list case alone cannot distinguish them. Choose cases by the mistakes they can expose.
The second calculation can answer a different question about an explicitly zero-filled table. It fails here because the promised result is the original available-value mean.
기초Foundations
24. 예상한 오류를 확인한 테스트는 성공할 수 있다24. A test confirming an expected error can pass
입력 ["bad"]에서 숫자 평균을 만들지 않겠다고 약속했다면 기대 결과는 숫자 0이 아니라 숫자 읽기 오류입니다. 실제로 그 오류가 발생하고 이름도 기대와 맞으면 이 테스트는 통과합니다.
오류를 아무 것이나 잡아서 성공이라고 하면 파일이 없거나 구현이 잘못된 오류도 섞일 수 있습니다. 고정 기록의 Python 테스트는 ValueError와 invalid-numeric-value 메시지를 함께 확인합니다. R 기록도 잡은 오류의 메시지를 기대 코드와 비교합니다.
반대로 정상값 2를 기대한 사례에서 예기치 않은 오류가 발생하면 통과가 아닙니다. 기대한 값·미정의·오류라는 세 결과 종류를 먼저 비교하고, 값이나 오류 코드가 필요한 경우 그 내용도 비교합니다.
If input ["bad"] is promised to raise a numeric-reading error, expected output is an error, not zero. Observing that specified error can pass the test.
Catching every error as success could conceal a missing file or an unrelated implementation bug. The fixed Python test checks ValueError and the invalid-numeric-value message; the R case compares the captured message with the expected code.
An unexpected error in a case expecting value two does not pass. First compare result kinds—value, undefined or error—then compare the value or error code when applicable.
기초Foundations
25. 작은 Python 테스트 네 개를 읽고 실행한다25. Read and run four small Python tests
아래는 이 네 입력에 대한 자족적인 설명 코드입니다. 가용값만 분수로 읽고, 가용값이 없으면 None을 반환합니다. 잘못된 숫자 글자는 Fraction에서 오류를 냅니다. 이 짧은 함수의 입력 범위는 위에 적은 작은 사례이며, 전체 실습의 모든 검증·계산 예산을 구현한 코드는 다운로드 프로그램에서 따로 읽습니다.
from fractions import Fraction
import unittest
def available_mean(values):
numbers = [Fraction(v) for v in values if v is not None]
return sum(numbers) / len(numbers) if numbers else None
class MeanCases(unittest.TestCase):
def test_available(self):
self.assertEqual(available_mean(["1", None, "3"]), 2)
def test_all_missing(self):
self.assertIsNone(available_mean([None]))
def test_empty(self):
self.assertIsNone(available_mean([]))
def test_bad_text(self):
with self.assertRaises(ValueError):
available_mean(["bad"])
if __name__ == "__main__":
unittest.main(verbosity=2)
test_로 시작하는 네 메서드가 각 기대를 검사합니다. assertEqual은 같은 값을, assertIsNone은 미정의를, assertRaises는 기대 오류를 확인합니다. 이런 메서드의 결과를 모으면 한 실패 뒤에도 다른 테스트 결과를 읽을 수 있습니다.
Python의 일반 assert 문은 최적화 실행 -O에서 제거될 수 있습니다. 일반 자료 검증을 반드시 수행해야 한다면 실행 모드와 오류 처리 절차를 명시하고, 이 장의 네 테스트처럼 테스트 도구가 보고하는 결과와 구별해 기록합니다. 고정 실행은 최적화 옵션 없이 실제 unittest를 사용했습니다.
This self-contained explanation covers the four stated inputs. It reads available values as fractions, returns None when none are available and lets Fraction reject invalid text. It is a small example; the downloadable programs contain the broader lab checks and computation limits.
from fractions import Fraction
import unittest
def available_mean(values):
numbers = [Fraction(v) for v in values if v is not None]
return sum(numbers) / len(numbers) if numbers else None
class MeanCases(unittest.TestCase):
def test_available(self):
self.assertEqual(available_mean(["1", None, "3"]), 2)
def test_all_missing(self):
self.assertIsNone(available_mean([None]))
def test_empty(self):
self.assertIsNone(available_mean([]))
def test_bad_text(self):
with self.assertRaises(ValueError):
available_mean(["bad"])
if __name__ == "__main__":
unittest.main(verbosity=2)
Four test_ methods check equality, an undefined return and an expected exception. The runner collects their outcomes so later cases can still be reported after a failure.
Ordinary Python assert statements can be removed under -O. If a data check must execute, specify its execution mode and explicit error handling, separately from the test framework’s report. The fixed references actually ran unittest without the optimization flag.
기초Foundations
26. R의 조건 확인과 오류 잡기를 나누어 읽는다26. Separate R condition checks from captured errors
같은 네 작은 입력을 base R만으로 확인할 수 있습니다. 아래 설명 함수는 유한한 숫자 문자열 또는 결측을 다루며, 숫자 변환 실패를 오류로 냅니다. 짧은 예제의 소수 계산은 R의 수치 근사입니다. 실제 분수 원문 파일을 읽는 고정 실행에는 분수 문자열 읽기 함수도 함께 들어 있습니다.
stopifnot에 넘기는 조건은 모두 참이어야 합니다. 거짓이나 NA가 섞이면 멈춥니다. tryCatch는 이 예제의 예상 오류를 잡아 그 메시지가 맞는지 확인합니다. 오류를 잡았다는 이유만으로 자료값을 0으로 바꾸지 않습니다.
고정 R 실행 기록은 네 사례의 결과를 먼저 모두 보존한 뒤 전체 통과 조건을 검사합니다. 그래서 의도적 실패 묶음에서도 어느 두 사례가 실패했는지 남습니다. Python 테스트 도구와 같은 라이브러리를 설치해 실행했다고 쓰지 않고 base R 절차임을 표시합니다.
Base R can check the same four small inputs. This explanatory function accepts finite numeric text or missingness and raises an error when conversion fails. Its arithmetic is numerical; fixed references additionally include a reader for retained fraction text.
stopifnot requires all supplied logical conditions to be true; false or NA stops evaluation. tryCatch captures the expected error here and checks its message, without turning the data value into zero.
The fixed R suite first retains all four case outcomes and then checks their conjunction. Both failures therefore remain visible in the deliberately failing suite. This is a base-R procedure, not a claim to have installed the Python framework or a separate R testing package.
기초Foundations
27. 실습 D · 실패를 드러내는 입력을 직접 고른다27. Lab D · Choose an input that exposes a bug
실습 D의 네 기본 기대를 가용평균 구현에 적용하세요. 네 개가 통과하는지 확인한 뒤 0 채움 평균으로 바꿉니다. 실행된 사례 수는 4이고 실패는 2입니다. 예상 숫자 오류를 확인한 네 번째 사례는 성공으로 셉니다.
첫 가용값만 반환하는 구현도 선택해 봅니다. 1·결측·3에서 1을 내므로 첫 기대 2와 다릅니다. 그런데 2·결측·2만 검사하면 첫 값 2가 우연히 평균과 같아 버그를 놓칩니다. 양쪽 입력을 나란히 손으로 계산해 보세요.
브라우저는 세 가지로 정한 JavaScript 구현에 선택 사례를 적용합니다. 임의 프로그램 문자열을 실행하는 도구가 아닙니다. 아래 실제 Python/R 기록의 실패 종료와 화면의 JavaScript 테스트 판정은 별도 경로입니다.
Apply the four default cases to the available-mean implementation: all four pass. Switch to the zero-filled implementation: four run and two fail. The fourth case, which confirms the expected numeric error, counts as a success.
Try the first-available implementation. It returns one rather than expected two for one/missing/three. Yet two/missing/two would miss this bug because its first value happens to equal its mean. Work out both inputs.
The browser applies selected cases to three declared JavaScript implementations. It does not execute arbitrary program text. Its test outcomes are separate from the archived Python/R processes and their exit statuses.
기초Foundations
28. 순서를 바꾸고 값을 이동해 또 다른 관계를 검사한다28. Check relations after permutation and a common shift
가용값 1과 3의 평균은 2입니다. 순서를 3·1로 바꾸어도 합과 가용 수가 같아 평균은 2입니다. 두 값에 각각 5를 더하면 6·8이 되어 평균은 7입니다. 원평균보다 5 커졌습니다.
유한한 가용값 n≥1개와 상수 a,b에 대해 값을 a+bxᵢ로 바꾸되 같은 결측 위치를 유지하면 아래 관계가 성립합니다. 원합을 전개하면 a가 n번 더해지고 b가 원합에 곱해지므로 직접 유도됩니다.
n1i=1∑n(a+bxi)=a+b(n1i=1∑nxi)
이처럼 정답 한 숫자 대신 입력 변환 전후의 관계를 검사할 수도 있습니다. 첫 가용값 구현도 공통 이동 관계는 만족하므로, 이 관계 하나만으로 평균 함수라고 판정하지 않습니다. 순열·기대값·빈 자료 검사를 목적에 맞게 함께 둡니다.
Values one and three have mean two. Reversing them preserves sum and count. Adding five to both produces six and eight, with mean seven—five above the original mean.
For n≥1 finite available values and constants a,b, transform every available value to a+bxᵢ while preserving the missing positions. Expanding the sum gives the following relation.
n1i=1∑n(a+bxi)=a+b(n1i=1∑nxi)
A test can compare this transformation relation instead of one expected number. But a first-available implementation also respects common shifts, so this property alone does not establish a mean. Combine properties and concrete expectations according to the errors they detect.
기초Foundations
29. 선택한 사례의 성공과 모든 입력의 증명을 나눈다29. Distinguish selected-case success from an all-input proof
함수가 처음 네 입력에서는 맞고 다섯 번째 입력에서만 잘못된다고 가정할 수 있습니다. 처음 네 개를 모두 통과했다는 사실과 이 가정은 모순되지 않습니다. 테스트가 확인한 입력을 표로 남기면 결론의 범위가 보입니다.
앞 절의 평균 이동 관계는 합을 전개하여 모든 유한 실수 값에 대해 증명했습니다. 실제 프로그램이 그 수학식을 정확히 구현하는지는 숫자 파싱·계산 범위·원목록 변경 여부도 확인해야 합니다. 종이에 증명한 식과 특정 프로그램의 모든 실행을 같은 주장으로 두지 않습니다.
입력 목록을 검사 전후에 비교하는 작은 시험도 유용합니다. 계산 함수가 평균을 내는 중 원목록의 결측 행을 삭제하면, 같은 입력을 뒤 검사에 넘긴다고 생각한 계획이 깨집니다. 실습의 함수들은 원입력을 보존한 결과를 반환하도록 작성했습니다.
A function could be correct on the first four inputs and wrong only on a fifth. Passing the first four does not contradict that possibility. Retain the tested inputs so the scope is visible.
The previous mean-shift relation was proved for all finite real values by expanding a sum. Whether a particular program implements it also depends on parsing, computation limits and input preservation. The paper identity and every execution of a specific program are different claims.
A before/after input comparison is also useful. If a mean function deletes missing rows in place, a later check no longer receives the input expected by the workflow. The lab functions return results while preserving the supplied input.
기초Foundations
30. 같은 코드를 실행한 환경을 작은 표로 남긴다30. Record the environment that actually ran the code
프로그램 파일이 같아도 읽는 파일 경로·문자 인코딩·출력 자릿수·시간대가 다르면 결과나 표시를 비교하기 어렵습니다. “내 컴퓨터에서는 된다” 대신 실제 사용한 실행 파일, 버전, 작업 폴더, 입력 파일을 적습니다.
이번 고정 기록은 Python 3.11.8·Matplotlib 3.10.0과 R 4.5.1을 실제로 실행했습니다. Python 그림은 Agg·DejaVu Sans·고정 SVG 설정을 사용했고 R 그림은 base SVG 장치를 사용했습니다. 실제 사례 동반 코드가 별도 환경에서 실행되었다면 그 버전을 이 기록과 바꿔 쓰지 않습니다.
R 프로그램은 options(digits=17,warn=1)과 UTC를 명시합니다. Windows의 문자 처리 locale도 UTF-8 설정으로 지정해 실제 결과에 남겼습니다. Python 자체 locale 관측 문자열은 이와 다를 수 있으며, 읽는 파일에는 UTF-8을 직접 지정했습니다. 모든 locale 범주가 언어 사이에서 같았다고 쓰지 않습니다.
The same program file can be hard to compare across different input paths, encodings, display digits or time zones. Record the executable, version, working directory and inputs actually used.
These fixed references ran Python 3.11.8 with Matplotlib 3.10.0, and R 4.5.1. Python used Agg, DejaVu Sans and declared SVG settings; R used its base SVG device. Keep any separate source-companion runtime versions distinct.
R programs explicitly declare options(digits=17,warn=1) and UTC, and set Windows character handling to a UTF-8 locale. Python’s observed locale string can differ; its file reads explicitly specify UTF-8. The records do not claim that every locale category matches across languages.
기초Foundations
31. 1/3을 짧게 인쇄해도 계산값이 달라진 것은 아니다31. A shorter printout does not change the computed value
고정 실행은 한 번 계산한 수치 1/3을 7자리 형식과 17자리 형식으로 각각 인쇄합니다. 실제 출력 문자열은 0.3333333과 0.33333333333333331입니다. 문자열은 다르지만 같은 내부 수를 두 번 형식화했습니다.
R의 digits는 일반 수치 인쇄의 유효 자릿수에 대한 설정입니다. 계산이 항상 그 자리에서 반올림된다는 뜻이 아닙니다. 이 비교 예제는 format(...,digits=7)과 format(...,digits=17)을 직접 사용하고, 전역 설정 17은 바꾸지 않았습니다.
다른 환경의 출력 파일을 비교할 때에는 원값·표시 형식·바이트를 나누어 봅니다. 인쇄 글자가 달라졌다고 계산이 틀렸다고 단정하지 않고, 같은 글자가 나왔다고 단위·분모·원행이 같다고 단정하지도 않습니다.
The fixed run formats one computed numerical 1/3 with seven and seventeen significant digits. The resulting strings are 0.3333333 and 0.33333333333333331. Different strings represent the same internal number used twice.
R’s digits setting concerns significant digits in ordinary numeric printing; it is not a command to round every computation to that many digits. The example explicitly calls format(...,digits=7) and format(...,digits=17) while leaving global digits at seventeen.
Compare value, presentation and bytes separately. Different print text alone does not establish a calculation error, while identical text alone does not establish matching units, denominators or source rows.
기초Foundations
32. 실습 E · 선언한 환경 기록을 비교한다32. Lab E · Compare declared environment records
실습 E는 실제 설치 프로그램을 검색하는 화면이 아니라 두 환경 기록 객체를 비교합니다. 기대 항목을 UTC와 R 출력 자릿수 17로 정한 뒤, 현재 기록의 자릿수를 7로 바꾸어 어느 조건이 실패하는지 확인하세요.
필수 필드를 하나 빼거나 null로 바꿔 보세요. 필드가 없는 것과 명시적 결측을 구별합니다. 숫자 17과 문자열 "17"도 타입을 보존해 비교하므로 같다고 처리하지 않습니다. 객체의 필드 나열 순서는 무시하지만 배열 원소 순서는 유지합니다.
아래 별도 고정 실행 두 종류는 실제 프로세스가 자기 버전·시간대·설정을 읽은 기록과, 같은 수의 두 표시 형식 비교입니다. 브라우저에 입력한 기록을 실제 설치 환경이라고 확인해 주는 기능과 구별해서 읽습니다.
Lab E compares two supplied environment objects; it does not search installed software. Require UTC and R display digits seventeen, then change the actual-record digits to seven and inspect the failed condition.
Remove a required field or set it to null. Absence differs from an explicit null. Numeric seventeen differs from string "17". Object-field order is ignored, while array order is preserved.
Two separate fixed references actually read their process environment or compare explicit print formats. They do not verify that a browser-supplied record describes the installed machine.
기초Foundations
33. 난수·행 순서·외부 상태를 필요한 만큼 고정한다33. Specify random generation, ordering and external state when relevant
평균 1과 3을 더하는 계산에는 난수가 필요하지 않습니다. 반면 표본 세 개를 임의로 고르는 코드에는 뽑기 절차와 초기 상태가 필요합니다. 같은 seed 숫자만 적고 언어·난수 생성 방식·뽑는 순서를 생략하면 같은 표본을 보장하지 못합니다.
자료를 어느 순서로 읽었는지도 남깁니다. 정확 분수 합은 순서를 바꾸어도 같지만 유한 정밀도 합은 순서에 따라 끝자리 차이가 날 수 있습니다. 최신 외부 파일을 자동으로 다시 받는 절차라면 입력 사본이 달라졌는지도 함께 봅니다.
이번 32개 고정 실행은 보관 파일만 읽으며 난수나 새 HTTP 요청을 사용하지 않습니다. 따라서 임의 seed를 꾸며 넣지 않고 이 사실을 기록합니다. 파일의 SHA256은 읽은 바이트를 다시 고르는 데 도움을 주며 자료 뜻은 별도 문서에서 읽습니다.
Adding one and three needs no randomness. Randomly selecting three observations requires a generation procedure and initial state. A seed number alone, without the generator, language and draw order, does not guarantee the same sample.
Record read order when relevant. Exact fraction sums are permutation-invariant; finite-precision sums can differ in their last digits. If a workflow automatically obtains the latest external file, also compare the retained input copies.
These thirty-two fixed runs use archived files without randomness or new HTTP requests. The records state that fact rather than inventing a seed. SHA256 helps identify the bytes read; documentation supplies their meaning.
기초Foundations
34. 프로그램·입력·결과를 연결해 다시 찾는다34. Link program, input and result artifacts
결과 숫자 2만 남기면 어떤 입력에서 나왔는지 알기 어렵습니다. 프로그램 경로, 입력 경로와 해시, 실행 명령, 실제 종료 상태, 표준 출력과 오류 출력을 한 기록에 묶습니다. 그림이 있으면 그 파일과 해시도 연결합니다.
해시는 파일 내용에서 계산하는 표식입니다. 같은 파일을 받았는지 비교하기에 유용하지만, 표식이 같다는 사실만으로 원자료가 참이거나 두 사람이 독립적으로 분석했다는 결론이 나오지 않습니다. 검사 코드가 같은 잘못된 기대를 공유했는지도 별도 검토할 수 있습니다.
이 장의 고정 기록은 프로그램 32개와 실제 그림 26개를 연결합니다. 환경 비교 네 프로그램과 의도적 실패 두 프로그램에는 그림이 없습니다. 없는 그림 링크를 만들어 성공한 실행처럼 보이게 하지 않습니다.
A result two alone is difficult to trace. Link the program, input paths and hashes, command, actual exit status, standard output and error output in one record. Link a plot and its hash when one exists.
A hash is a content-derived marker useful for comparing files. Agreement alone does not establish source truth or independent reasoning by two analysts. Review whether checkers shared an incorrect expectation separately.
This catalog links thirty-two programs and twenty-six actual plots. Four environment programs and two deliberately failing programs have no plots. Their records do not invent missing graphics.
기초Foundations
35. 실행 성공·데이터 조건 실패·예상 실패를 구별한다35. Separate successful execution, failed data checks and expected exits
원행 수를 4로 기대했지만 실제로 3을 받은 프로그램은 “원행 수 조건 실패”라는 결과를 정상적으로 출력할 수 있습니다. 이때 프로세스 종료 코드는 0입니다. 자료 조건의 참·거짓과 프로그램 실행 완료는 다른 칸입니다.
의도적으로 잘못 만든 0 채움 평균의 테스트 묶음은 네 개 중 두 개가 실패합니다. Python은 실제 테스트 결과를, R은 네 판정과 마지막 조건 오류를 남기며 두 프로그램 모두 비영 종료 상태입니다. 예상 실패라는 이름은 실패를 숨기는 말이 아니라 수업에서 이 종료를 미리 기대했다는 표시입니다.
이번 기록은 총 32개 중 성공 종료 30개·예상 비영 종료 2개입니다. 실패 프로그램도 테스트 네 개와 실패 두 개의 요약을 보존했습니다. 성공 프로그램 30개 중 그림 26개·환경 텍스트만 네 개입니다. 이런 개수 관계를 직접 맞춰 봅니다.
A program expecting four rows but observing three can correctly output “row-count condition failed” and exit zero. The condition’s truth and process completion occupy different fields.
The deliberately incorrect zero-filled suite fails two of four cases. Python retains its native test report; R retains all outcomes and a final condition error. Both exit nonzero. “Expected failure” states the declared teaching expectation rather than hiding the failure.
Of thirty-two runs, thirty exit successfully and two exit nonzero as expected. The failed processes still retain four-test/two-failure summaries. Among thirty successful runs, twenty-six produce plots and four environment programs are text-only. Reconcile these counts directly.
기초Foundations
36. 실습 F · 실제 원행에 계약을 적용한다36. Lab F · Apply contracts to actual retained rows
국가에서는 두 페이지 전체와 첫 페이지 선택을 바꿉니다. 개인에서는 원시급과 원 로그 필드를 바꾸고 원행 번호를 선택합니다. 점포에서는 원행 키와 원 코드의 고유성을 비교한 뒤, 원행 42 또는 168을 뺀 가정 비교를 별도 표로 확인합니다.
화면은 동결된 실제 사례 모델의 원행을 JavaScript로 읽어 다시 계산합니다. 이 입력 선택을 새로운 Python/R 실행이나 새로운 자료 수집으로 표시하지 않습니다. 원자료 전체는 비교 중에도 보존하며 잘못된 삭제 선택은 별도 사본의 효과로 표시합니다.
이제 세 맥락을 한 번씩 손으로 따라가겠습니다. 같은 고유성·가용성이라는 이름이 실제 어떤 열과 분모를 가리키는지 표와 원행에서 확인하세요.
For country data, switch between all pages and first-page selection. For people, switch raw wage/source-log fields and select a source row. For stores, compare source-row keys with original codes, then inspect separate hypothetical deletion contrasts for row forty-two or 168.
The browser recalculates frozen actual case rows in JavaScript. These controls do not represent new Python/R runs or new collection. Original rows remain retained, with invalid deletion choices shown as effects on separate comparison copies.
Work through all three contexts by hand. Locate the particular field and denominator behind each uniqueness or availability statement.
기초Foundations
37. 국가의 여섯 연도와 첫 페이지 세 연도를 비교한다37. Compare six annual keys with three first-page keys
보관 국가 표는 한국의 동일 GDP 지표에 대해 2019–2024년 여섯 키를 담습니다. 첫 페이지의 관측 연도는 2022·2023·2024이고 둘째 페이지는 2019·2020·2021입니다. 공개 CSV는 연도 순서로 정리하면서 원 페이지·페이지 안 위치도 보존했습니다.
실제 보관 응답의 키 범위
선택
행 수
서로 다른 연도
필요한데 없는 연도
두 페이지 전체
6
6
없음
첫 페이지
3
3
2019·2020·2021
첫 페이지 안의 키는 고유하고 값도 가용합니다. 그러나 기대한 여섯 연도를 모두 받았다는 계약은 통과하지 않습니다. “현재 받은 키가 서로 다르다”와 “필요한 키를 전부 받았다”를 따로 검사해야 하는 실제 예입니다.
이 계약은 보관 응답 범위의 확인입니다. HTTP 교환을 새로 실행하거나 미래 자료가 같은 값일 것이라고 확인한 것은 아닙니다. 관측 연도·원문의 갱신 날짜·수집 시점도 각각 다른 역할로 남깁니다.
The retained table contains six Korean GDP-indicator keys for 2019–2024. Page one covers 2022/2023/2024; page two covers 2019/2020/2021. The public CSV orders years while retaining original page and within-page position.
Key coverage in the retained responses
Selection
Rows
Distinct years
Required but absent
Both pages
6
6
None
First page
3
3
2019/2020/2021
First-page keys are unique and their values are available, yet the six-year completeness contract fails. “Received keys are distinct” and “all required keys were received” need separate checks.
This concerns archived response coverage. It does not perform another HTTP exchange or establish future values. Observation year, source-update date and collection date retain separate roles.
기초Foundations
38. 원시급과 원 로그의 가용 수를 따로 센다38. Count raw-wage and source-log availability separately
실제 개인 파일은 3,613개 원행을 모두 남깁니다. 원시급은 3,017개 가용·596개 결측, 원 로그는 3,010개 가용·603개 결측입니다. 원시급은 있지만 원 로그가 없는 일곱 원행도 별도 표에 남습니다.
같은 원행 집합 안의 서로 다른 필드
필드
전체
가용
결측
1976 원시급
3613
3017
596
원문 절단 로그
3613
3010
603
원시급의 가용 합은 1,738,060센트/시간이며 그 필드의 평균은 1,738,060/3,017입니다. 이 합을 3,613으로 나누면 결측을 0으로 채운 다른 평균입니다. 원 로그의 가용평균도 자기 분모 3,010을 사용합니다.
일곱 차이 행이 있다는 관측은 원 로그의 처리 규칙을 새로 복원했다는 뜻이 아닙니다. 원문이 제공한 두 필드와 가용 여부를 보존합니다. 원행 번호는 사본의 기록을 찾는 키이며 사람의 고유 신분이라고 주장하지 않습니다.
The actual person file retains all 3,613 source rows. Raw wage is available for 3,017 and missing for 596; the source log is available for 3,010 and missing for 603. Seven rows have raw wage but unavailable source log.
Different fields on the same retained row set
Field
All rows
Available
Missing
1976 raw wage
3613
3017
596
Source-trimmed log
3613
3010
603
Available raw wages sum to 1,738,060 cents per hour, giving mean 1,738,060/3,017. Dividing by 3,613 instead gives a separate zero-filled mean. The source-log mean uses its own denominator 3,010.
Observing seven differing availability states does not reconstruct the source trimming rule. Preserve the two supplied fields and their flags. Source positions locate records in the copy; they do not establish unique person identities.
기초Foundations
39. 원 코드 407의 두 실제 기록을 함께 읽는다39. Read both actual records with original code 407
점포 원행 42는 PA·체인 2·전 FTE 11·후 FTE 11입니다. 원행 168은 NJ·체인 4·전 12·후 14.5입니다. 둘 다 원 코드 407이지만 변화량은 각각 0과 2.5FTE입니다.
서로 다른 원행을 반복 코드만으로 합치지 않음
원행
원 코드
주
체인
전 FTE
후 FTE
변화
42
407
PA
2
11
11
0
168
407
NJ
4
12
14.5
2.5
원행 번호를 키로 쓰면 410개가 고유합니다. 원 코드로 쓰면 서로 다른 값은 409개이고 반복 그룹에 이 두 행이 들어갑니다. 어느 결과도 자동으로 원행을 지우지 않습니다.
이 사본의 원행 번호는 다시 계산할 기록을 정확히 고르는 데 유용합니다. 코드 반복과 두 행의 다른 필드는 관찰 사실입니다. 두 행이 실제 같은 점포의 오기인지 아닌지까지 원행 위치가 입증하는 것은 아니므로, 임의 중복 삭제를 정당화하지 않습니다.
Store source row forty-two records PA, chain two, FTE eleven before and after. Row 168 records NJ, chain four, FTE twelve before and 14.5 after. Both carry original code 407, but their changes are zero and 2.5 FTE.
Do not merge source rows solely by repeated code
Source row
Original code
State
Chain
Before
After
Change
42
407
PA
2
11
11
0
168
407
NJ
4
12
14.5
2.5
Source-row keys are unique across 410 records. Original codes have 409 distinct values, with these two records in one repeated group. Neither result automatically removes a row.
Source positions help select records for recalculation. The repeated code and differing fields are observations. Positions alone do not prove a real-world identity or justify arbitrary duplicate deletion.
기초Foundations
40. 한 행을 지우면 평균 분모와 분자가 함께 바뀐다40. Deleting one row changes both numerator and denominator
전체 410행 중 전후 FTE가 같은 원행에 모두 있는 완전짝은 384개이고, 그 변화 합은 −541/20FTE입니다. 평균은 −541/7,680FTE입니다. 원행 42의 변화 0을 빼면 합은 그대로지만 완전짝 수는 383이 됩니다.
원행 168의 변화 5/2를 빼면 합도 −591/20으로 바뀝니다. 둘 중 무엇을 지웠는지에 따라 평균이 다릅니다. 아래는 정당한 삭제 권고가 아니라 반복 코드를 이유로 임의 삭제했을 때의 별도 가정 비교입니다.
원본 표는 어떤 비교에서도 410행·384완전짝을 유지합니다. “고유 코드 수를 맞췄다”는 하나의 목표를 위해 행을 버리면 원래 요약 질문까지 바뀔 수 있음을 숫자로 확인합니다.
Among 410 records, 384 have both FTE waves on the same source row. Their changes sum to −541/20 FTE, giving mean −541/7,680. Removing row forty-two’s zero change leaves the sum but reduces complete count to 383.
Removing row 168’s change 5/2 also changes the sum to −591/20. The resulting means differ. These are separate hypothetical consequences of invalid code-based deletion, not recommendations.
The original table retains 410 rows and 384 complete pairs throughout. Meeting a chosen unique-code count by discarding a record can change the original summary question.
기초Foundations
41. 0 채움 평균과 가용평균의 차이를 유도한다41. Derive the zero-filled versus available-mean relation
전체 N개 중 가용 n≥1개가 있고 나머지 칸을 0으로 채운다고 합시다. 두 표의 가용 합 S는 같지만 분모는 다릅니다. 따라서 0 채움 평균은 가용평균에 가용 비율 n/N을 곱한 값입니다.
가용평균이 양수이고 결측이 하나 이상이면 0 채움 평균은 더 작습니다. 가용평균이 음수면 덜 음수로 바뀌고, 원 가용평균이 0이면 둘은 우연히 같습니다. 숫자 하나가 같아도 같은 정의를 썼다는 뜻은 아닙니다.
n=0에서는 가용평균이 미정의이므로 이 관계를 적용하지 않습니다. N≥1이면 0만 채운 표의 평균은 0일 수 있지만, 이는 원래 아무 값도 관측하지 못한 상황에 새 값을 넣은 별도 계산입니다.
Suppose N total rows include n≥1 available values, and every other field is filled with zero. Sum S is unchanged, while the denominator changes. The zero-filled mean is the available mean times n/N.
With a positive available mean and at least one missing field, zero filling reduces the mean. A negative mean moves toward zero; an available mean zero happens to agree. Equal numbers alone do not establish equal definitions.
Do not apply this identity at n=0, where the available mean is undefined. If N≥1, an entirely zero-filled table can have mean zero, but that is a new calculation after inserting values.
기초Foundations
42. 작은 부분표의 합과 개수를 모아 전체를 검산한다42. Recombine disjoint parts using their sums and counts
가용값 1·3과 10을 두 집단으로 나누면 집단 평균은 2와 10입니다. 집단 평균을 단순 평균하면 6이지만, 전체 세 값의 평균은 14/3입니다. 가용 수 2와 1을 가중치로 써야 전체 평균이 나옵니다.
양의 정수 G에 대해 유한한 가용값을 겹치지 않는 G개 집단으로 나누고 각 n_g≥1이라 합시다. 전체 n은 집단 가용 수의 합이고 전체 합은 집단 합의 합입니다. 아래 식은 이 두 사실을 분모 n으로 나눈 결과입니다.
n=g=1∑GngS=g=1∑Gngxˉgxˉ=g=1∑Gnngxˉg
페이지·파일·집단을 합치는 계약에서 이런 검산이 유용합니다. 빈 가용 집단은 평균을 억지로 만들지 말고 합 0·가용 수 0으로 합칩니다. 행이 여러 부분에 중복 포함되면 같은 값을 반복 세므로 먼저 부분표의 겹침과 키를 확인합니다.
Split available values one/three and ten into groups. Group means are two and ten. Their unweighted average six differs from the full mean 14/3. Available counts two and one supply the correct weights.
For a positive integer G, partition finite available values into G disjoint groups with n_g≥1. Total available count and sum are sums of the group counts and sums, giving the following identity.
n=g=1∑GngS=g=1∑Gngxˉgxˉ=g=1∑Gnngxˉg
This checks recombination across pages, files or groups. For a group with no available values, combine its zero sum and zero count without inventing a mean. Overlapping parts count rows repeatedly, so check their keys and overlap first.
기초Foundations
43. 성분 보존 표현이 키 충돌을 막는 이유를 증명한다43. Explain why component-preserving representation avoids collisions
선택 심화입니다. 각 허용 성분을 타입과 값의 쌍으로 표현하고, 성분들의 순서를 보존한 목록을 사용합니다. 이 표현을 다시 읽었을 때 원래 각 타입·값·순서를 복원할 수 있다고 가정합니다.
서로 다른 두 원키가 같은 표현을 가졌다고 가정해 봅시다. 그 표현을 다시 읽으면 하나의 원키만 복원되어야 하는데, 복원 가능성에 의해 두 원키 모두 그 하나와 같아야 합니다. 따라서 원키 둘이 다르다는 가정과 모순됩니다. 이것이 일대일 표현의 간단한 증명입니다.
구분자를 무조건 붙인 문자열은 역복원이 유일하지 않아 이 전제를 만족하지 않습니다. 해시만 비교하는 방식도 유한한 출력 공간이므로 모든 가능한 키에서 충돌이 없다는 같은 증명을 쓸 수 없습니다. 실습 B는 해시를 사람·점포의 신원으로 사용하지 않고 타입을 보존한 조합 자체를 비교합니다.
Optional extension: encode each allowed component as its type/value pair and retain component order in a list. Assume decoding recovers every original type, value and position.
If two different original keys had the same representation, decoding that representation would recover one key. Recoverability would make both originals equal to that key, contradicting their assumed difference. This proves injectivity.
Unescaped delimiter concatenation lacks unique decoding and does not satisfy the premise. A finite-output hash also cannot use this argument to establish collision freedom over all possible keys. Lab B compares typed tuples rather than treating a hash as person or store identity.
기초Foundations
44. 무작위 테스트의 발견 확률에도 조건이 필요하다44. State the sampling law behind random-test detection probabilities
선택 심화입니다. 설명용 입력 모집합에서 한 번 뽑은 입력이 버그를 드러낼 확률을 p∈[0,1]이라고 합시다. 양의 정수 m≥1에 대해 같은 법칙에서 독립·복원으로 m번 뽑는다는 추가 가정을 두면, 한 번도 드러내지 못할 확률은 (1−p)^m입니다. 적어도 한 번 발견할 확률은 그 여사건입니다.
P(no detection)=(1−p)mP(detection)=1−(1−p)m
예를 들어 p=1/4이고 독립 두 번이면 발견 확률은 1−(3/4)²=7/16입니다. 두 번 모두 같은 입력을 재사용한다면 독립 두 번이라는 가정이 깨져 이 수를 붙일 수 없습니다.
이 장의 기본 네 테스트는 목적에 맞게 고른 고정 사례입니다. 위 임의 추출 법칙으로 실제 뽑은 사례가 아니므로 네 개의 통과에서 버그 확률이나 보증 수준을 계산하지 않습니다. 확률식을 사용할 때는 입력을 뽑는 법칙부터 명시합니다.
Optional extension: under a declared input population, let one draw expose a bug with probability p∈[0,1]. For a positive integer m≥1, take m independent draws with replacement from that same law. No detection has probability (1−p)^m; its complement gives detection.
P(no detection)=(1−p)mP(detection)=1−(1−p)m
For p=1/4 and two independent draws, detection probability is 7/16. Reusing the same sampled input twice breaks the independent-draw premise.
The chapter’s four default tests are fixed, deliberately selected cases, not draws from this law. Their passage does not supply a bug probability or guarantee level. Specify input sampling before using such a formula.
기초Foundations
45. 단계별 계약을 연결할 때 넘기는 값도 확인한다45. Check the values passed between contracted stages
첫 단계가 세 행을 읽고 둘째 단계가 평균을 계산한다고 합시다. 첫 단계의 출력 약속이 “세 원행을 그대로 반환한다”이고 둘째 단계의 입력 약속이 “숫자 문자열 또는 결측 목록”이면, 그 사이에 어떤 열을 골라 넘기는지도 필요합니다. 원 코드 열을 값 열로 잘못 넘기면 각 단계의 이름만 맞아도 계산은 달라집니다.
전제 P에서 함수 f가 중간 성질 Q를 보장하고, Q를 만족하는 입력에 함수 g가 성질 R을 보장한다고 합시다. 같은 중간값을 실제로 넘기고 두 단계가 정상 종료한다면 합성 계산은 P에서 R을 보장합니다. 이것은 두 함수를 순서대로 적용하는 논리입니다.
하지만 파일 읽기 중 외부 상태가 바뀌거나 f가 반환하지 않은 오래된 값을 g에 넘기면 같은 전제가 아닙니다. 실제 실행 기록에서 어떤 파일·열·출력이 다음 입력이 되었는지 연결해야 논리의 전제를 점검할 수 있습니다.
Suppose one stage reads three rows and another computes a mean. Promising to retain rows and accepting numeric-text/missing inputs still leaves a choice: which column is passed? Accidentally passing a business-code column changes the calculation.
Suppose f guarantees intermediate property Q under precondition P, and g guarantees R for inputs satisfying Q. If the same intermediate value is passed and both terminate normally, their composition guarantees R under P.
A changed external file or an old value passed instead of f’s output breaks those premises. Link actual files, columns and intermediate outputs so this composition argument can be checked.
기초Foundations
46. 한 장의 검사 기록을 완성한다46. Complete one inspectable testing record
세 행 예제로 돌아와 짧은 기록을 완성해 봅시다. 받은 원표·결측 표시를 보존하고, 가용평균이라는 질문과 기대 2의 손계산을 적습니다. 원행 수 3·가용 수 2·키 선택·정상값과 오류 사례를 함께 둡니다.
그다음 실제 실행 파일과 명령, 버전·표시 설정, 성공/실패 판정과 원출력을 연결합니다. 같은 숫자가 나와도 다른 입력을 쓴 것은 아닌지, 실패를 없애려고 행을 바꾸지는 않았는지, 검사하지 않은 범위를 과장하지 않았는지 기록으로 확인합니다.
다음 장에서는 이 검사 과정을 독자에게 전달하는 표·그림·설명을 다룹니다. 고유한 키·같은 단위·분명한 분모를 확인한 뒤, 독자가 숫자를 스스로 읽을 수 있는 제목과 주석으로 연결합니다.
Return to the three-row example. Preserve the original table and missing flags, state the available-mean question and work out expected two. Include total three, available two, the chosen key and both normal and error cases.
Link the actual program, command, versions, display settings, outcome and raw output. Use those records to check whether equal numbers came from equal inputs, whether rows were changed to remove a failure and what remains untested.
The next chapter turns these checks into tables, graphics and explanations for readers. Verified keys, units and denominators support titles and notes that let a reader interpret the numbers.
기초Foundations
47. 실제 국가·개인·점포 사례를 다시 연결한다47. Reconnect the actual country, person and store cases
국가 자료 · 프로그램이 멈추지 않았다고 여섯 해가 모두 온 것은 아니다
2019~2024년 한국의 1인당 실질 GDP를 찾는다고 합시다. 원하는 결과는 특정 지표·국가·연도의 여섯 관측입니다. 실제 World Bank API에 한 페이지당 3행을 요청한 보관 원문은 두 페이지이고, 각 페이지에는 3행이 있습니다. 첫 페이지의 JSON 문법이 맞고 숫자가 모두 양수이며 요청이 성공했어도 여섯 해가 모두 수집됐다는 뜻은 아닙니다. 이 장에서는 실제 원문을 다시 읽어 요청의 성공, 자료 구조, 분석에 필요한 완전성을 서로 다른 검사로 나눕니다.
자료 계약은 컴퓨터에 숫자만 달라는 부탁보다 구체적입니다. 국가 코드는 KOR, 지표 코드는 NY.GDP.PCAP.KD, 연도는 2019부터 2024까지라는 조건을 먼저 적습니다. 한 행의 뜻은 국가·지표·연도의 조합이며, 그 조합이 중복되지 않아야 합니다. 이 GDP의 단위는 2015년 불변 미국 달러/명입니다. 구매력평가 달러나 가구의 소득, 개인별 실측 임금으로 이름을 바꾸지 않습니다. 기대하는 행 수 6은 이 요청의 정의에서 나온 것이며 모든 API에 공통으로 붙이는 마법 숫자가 아닙니다.
실제 요청의 완전성과 선언한 검사 · 첫 선택만 불완전
읽은 범위
실제 반환 행
선언한 목표 행
여섯 해 계약 충족?
원문 1페이지
3
6
아니오 · 예상한 거절
원문 1+2페이지
6
6
예 · 이 범위의 완전성
첫 페이지가 불완전하다는 검사는 자료 제공자가 틀렸다는 판정이 아닙니다. 3행씩 보내 달라는 요청에 맞게 첫 3행을 받은 것입니다. 잘못은 그 중간 결과를 최종 여섯 해 자료라고 넘기는 데 있습니다. 반대로 합친 결과의 행 수가 6이라고 해도 같은 해를 두 번 넣고 다른 해를 빠뜨렸을 수 있으므로, 행 수뿐 아니라 실제 키의 집합까지 검사합니다. 날짜 표시의 모양만 맞는지, 목표 연도가 모두 있는지도 따로 확인합니다.
보관한 두 응답의 갱신일은 자료의 빈티지 정보이며, 내려받은 날짜는 수집 기록입니다. 실제 측정 대상 연도와 같지 않습니다. SHA-256은 재실행할 때 같은 바이트를 읽는지 확인하는 지문입니다. 그 지문이 맞는다고 기관의 원 추계가 절대적으로 정확하다거나 앞으로 수정되지 않는다는 뜻은 아닙니다. 이 장의 검사는 해당 보관 사본에 대한 추적과 조건 충족을 보장하는 범위로 읽습니다.
먼저 생각한 뒤 풀이 보기: 행 수 6과 모든 값이 양수라는 검사만 통과하면 충분한가요?
아닙니다. 국가·지표·연도 키, 여섯 연도의 집합, 단위와 결측 가능성까지 질문에 맞춰 정합니다. 같은 2024년을 여섯 번 넣은 잘못된 선택도 행 수와 양수 검사만으로는 통과할 수 있습니다. 이런 예를 실습에서 만들 경우 원문을 수정하지 않고 별도 가정 검사 입력으로 표시합니다.
먼저 생각한 뒤 풀이 보기: 검사 프로그램이 모두 통과하면 국가 간 인과 비교도 믿어도 되나요?
검사한 속성에 대해서만 확인했습니다. 잘못된 질문, 대표성, 측정오차, 정책과 결과 사이의 교란은 행 수나 해시 검사로 해결되지 않습니다. 계산 재현성과 연구 결론의 타당성은 관련이 있지만 같은 판정이 아닙니다.
개인 자료 · 원시 임금과 제공 로그의 결측 계약을 따로 쓰기
Card의 실제 익명 고정폭 자료에는 3,613개 원행이 있습니다. 1976년 시간당 임금의 원시 값은 센트 단위이고, 제공된 로그 임금은 원 저자가 이상치를 절단해 제공한 별도 변수입니다. 원시 임금은 3,017행에, 제공 로그는 3,010행에 가용합니다. 원시 값이 있으면서 제공 로그가 없는 실제 7행을 선택 CSV에 그대로 보관했습니다. 원 저자의 절단 기준을 이 차이만으로 역으로 알아낸 것으로 주장하지 않습니다.
실제 원 필드의 가용성 · 같은 3,613원행을 보존
원 변수
원행 수
가용 값
가용하지 않은 값
1976 원시 시급 · 센트/시간
3613
3017
596
제공된 절단 로그 · 센트 시급의 로그
3613
3010
603
초보자는 “로그는 원시 값에서 만들었으니 둘의 결측 위치가 같을 것이다”라는 검사를 먼저 작성할 수 있습니다. 실제 자료는 이 가정을 거절합니다. 이때 정답은 검사를 통과시키려고 7행을 지우는 것이 아니라 두 필드의 뜻을 다시 읽고 계약을 고치는 것입니다. 새로운 로그를 직접 계산하는 연구를 한다면 원 필드와 구별된 이름을 붙이고 계산 가능 범위와 목적을 밝힙니다. 새로 계산한 로그를 원 저자가 제공한 절단 로그와 같은 변수라고 덮어쓰지 않습니다.
결측을 숫자 0으로 바꿔도 프로그램은 평균을 계산할 수 있습니다. 그러나 그 결과가 원자료 평균이라는 보장은 없습니다. 제공 로그의 가용 평균은 3,010을 분모로 쓰고, 603개 결측을 0으로 바꾼 별도 계산은 3,613을 씁니다. 이 차이는 컴퓨터의 오차가 아니라 자료와 분석 대상을 바꾼 결과입니다. 선택 CSV는 가용하지 않은 원 필드를 빈 값으로 남기고, 0채움 비교는 유효한 원자료가 아닌 명시한 잘못된 처리 예로 분리합니다.
다운로드한 Python 재현 코드는 원 ZIP의 실제 고정폭 구간을 다시 읽고 Fraction으로 정확한 분모·합·평균을 계산합니다. R 코드는 같은 원문을 독립적으로 읽고 base R로 다시 계산합니다. 두 코드가 원사례 JSON이나 앞선 결과 숫자를 읽어 답을 복사하지 않게 구성했습니다. R의 일반 부동소수점과 Python의 정확 분수를 비교할 때는 허용오차와 작은 비영 값의 상대오차 검사를 따로 둡니다. 환경 기록은 숫자 결과와 분리해 실제 실행 버전과 코드·입력 지문을 추적합니다.
먼저 생각한 뒤 풀이 보기: 제공 로그가 없는 7행의 원시 시급에 로그를 취하면 원 결측이 복구되나요?
새로운 변환 변수는 만들 수 있지만 원 저자의 절단 로그가 복구됐다고는 할 수 없습니다. 원 절단 기준을 확인하지 않은 상태에서는 서로 다른 변수입니다. 원 필드·새 필드·가용 범위를 함께 보관해야 합니다.
먼저 생각한 뒤 풀이 보기: 원본 해시와 코드 버전만 같으면 모든 컴퓨터의 소수 끝자리도 같은가요?
항상 그렇지는 않습니다. 실행기·라이브러리·연산 순서·부동소수점 계산 등에 따라 차이가 날 수 있습니다. 정확한 정수·분수 불변량과 허용오차가 필요한 근삿값을 구분하고, 실패가 자료·코드·환경 중 어디에서 왔는지 좁혀 봅니다. 같은 환경 자체가 원자료의 대표성을 보장하지도 않습니다.
점포 자료 · 같은 코드 407 두 행을 오류라고 지우면 무엇이 달라지나
실제 뉴저지·펜실베이니아 최저임금 연구 원문에는 410개 원행과 두 시점의 고용 기록이 있습니다. 한 원행에 들어 있는 두 시점 값을 짝지으며, FTE는 전일제+0.5×시간제+관리자로 계산합니다. 필요한 세 성분이 모두 있을 때만 각 시점 FTE를 계산하고, 두 시점이 모두 가용한 384행에서만 관측 차이를 계산합니다. 나머지 26행은 버리지 않습니다. 이 단순 관측 차이 자체를 추가 식별 없이 정책의 인과효과라고 부르지 않습니다.
원 점포 코드의 서로 다른 값은 409개입니다. 407이 원행 42와 168에 각각 나오며, 주·체인·두 시점 값이 다릅니다. 따라서 “코드는 고유해야 한다”는 검사는 원문에서 실패합니다. 두 행이 같은 현실 점포를 잘못 반복한 것이라는 증거가 없으므로, 한 행을 삭제해 자료를 그 가정에 맞추지 않습니다. source_row_id는 이 보관 원문의 위치를 추적하기 위한 고유 키입니다. 표본의 독립성, 다른 파일에서도 같은 점포라는 사실, 시간에 걸친 영구 식별자를 자동으로 보장하지 않습니다.
실제 원 코드 407의 두 기록 · 값은 FTE
원행 키
원 코드
주
체인 코드
전
후
관측 차이
42
407
PA
2
11
11
0
168
407
NJ
4
12
29/2
5/2
원행 보존 대 명시한 잘못된 삭제 처리 · 평균 소수는 반올림
처리 규칙
원행 수
완전짝 수
평균 관측 차이 ·FTE
모든 원행 보존
410
384
-0.070442708
잘못된 첫 코드만 유지 ·168삭제
409
383
-0.077154047
잘못된 마지막 코드만 유지 ·42삭제
409
383
-0.070626632
세 결과는 서로 다른 세 기업이나 세 정책 실험이 아닙니다. 같은 원문에 저자가 명시한 처리 규칙을 적용해 숫자가 어떻게 달라지는지 확인한 것입니다. 잘못된 삭제 사례도 학습용으로 공개하지만, 이를 유효한 청소 방법이나 제공자가 수정한 새로운 빈티지라고 표시하지 않습니다. 첫 행과 마지막 행 중 어느 쪽을 남겼는지에 따라 평균이 달라지는 현상은 임의 삭제가 분석에 영향을 준다는 증거이며 어느 평균이 인과효과인지 정해 주는 증거는 아닙니다.
최종 검사표의 12개 중 4개는 관측 규칙이 거짓일 것을 예상하는 검사입니다. 첫 페이지만으로 완전하다는 주장, 원시·로그 결측이 같다는 주장, 원 로그 결측에 숫자를 넣어도 보존됐다는 주장, 원 코드가 모두 고유하다는 주장입니다. 테스트 프로그램이 이 거절을 확인하면 그 테스트는 통과합니다. “실패를 예상한 테스트가 통과했다”와 “잘못된 자료를 정상이라고 받아들였다”는 반대입니다. 코드는 기대한 예외를 처리하고 예상하지 못한 실패는 실행 오류로 남깁니다.
먼저 생각한 뒤 풀이 보기: 검사에 실패했으니 원자료에 중복 오류가 있다고 결론 내려도 되나요?
검사 조건 자체가 잘못됐을 수 있습니다. 코드가 어떤 범위에서 고유하다고 정의됐는지 확인하고 원행의 다른 필드를 봅니다. 지금 원문은 두 407행을 별도로 보존할 근거를 제공하며, 같은 실제 점포의 잘못된 반복이라는 근거를 제공하지 않습니다.
먼저 생각한 뒤 풀이 보기: 버전·해시·검사표를 함께 보관하는 이유는 무엇인가요?
같은 숫자를 재현하지 못했을 때 바뀐 입력, 바뀐 처리, 다른 실행 환경을 구분하기 위해서입니다. 공개 실행 기록에는 필요한 버전·입력/코드 지문을 남기고 사용자 이름·호스트·비밀 환경변수 같은 불필요한 개인 정보는 넣지 않습니다. 환경 고정은 추적 수단이며 타당한 질문이나 통계 가정을 대신하지 않습니다.
Country data · A successful request does not prove six years arrived
Suppose the question needs Korean real GDP per capita for 2019–2024: six observations with a specified indicator, country and year. The retained actual World Bank request asks for three records per page and returns two pages of three. Valid JSON, positive numbers and a successful first request do not establish six-year completeness. Re-read the actual archived responses and distinguish request success, structural checks and completeness for the intended analysis.
A data contract is more specific than “give me numbers.” Declare country KOR, indicator NY.GDP.PCAP.KD and years 2019 through 2024. A row represents a country–indicator–year combination, whose key must be unique in the extract. Units are constant 2015 U.S. dollars per person, not PPP dollars, household income or personal wages. The expected count of six follows from this request definition; it is not a universal API constant.
Actual request coverage and declared checks · first selection is incomplete
Read scope
Actual returned rows
Declared target rows
Six-year contract met?
Original page 1
3
6
No · expected rejection
Original pages 1+2
6
6
Yes · completeness within this scope
Rejecting the first page as incomplete is not a finding that the producer is wrong. It correctly supplies three records under the request. The mistake would be treating an intermediate response as the final six-year extract. Conversely, six rows alone could contain a repeated year and omit another. Check the actual set of semantic keys as well as the count, and distinguish a date’s format from coverage of the required years.
The response update field describes the data vintage, while the download date records collection. Neither is the observation year. SHA-256 fingerprints whether reruns use the same bytes; a matching fingerprint does not prove an estimate perfectly accurate or immune to future revision. Read these checks as traceability and contract checks on a specified retained snapshot.
Think first, then reveal: Are six rows and positive values sufficient?
No. Specify semantic keys, the six-year set, units and permitted unavailability for the question. Six copies of 2024 could pass count and positivity alone. A deliberately broken test fixture is a separate in-memory example, never a rewritten actual source.
Think first, then reveal: Do passing tests validate a causal comparison between countries?
They confirm only the checked properties. An unsuitable question, representativeness, measurement error or confounding is not resolved by counts or hashes. Computational reproduction and validity of a research conclusion are related but different assessments.
Person data · Separate missingness contracts for raw wages and supplied logs
The actual anonymous Card fixed-width file contains 3,613 source records. Raw 1976 hourly wages are in cents; supplied log wages are a distinct source variable described as outlier trimmed. Raw wages are available for 3,017 records and supplied logs for 3,010. Retain the actual seven raw-available/log-unavailable records in a selected CSV. Their difference does not reconstruct the source author’s trimming rule.
Actual source-field availability · preserve the same 3,613 rows
Source variable
Original records
Available values
Unavailable values
1976 raw wage · cents/hour
3613
3017
596
Supplied trimmed log of cents/hour
3613
3010
603
A beginner might assert that logs and raw values must share the same missingness. The actual source rejects that assumption. The remedy is to reread the field definitions and revise the contract, not delete seven rows to force a pass. A research choice to calculate a new log requires a separate variable name and declared eligibility and purpose. It must not overwrite the author-supplied trimmed-log field as though they were identical.
Replacing unavailable fields with zero still lets software calculate a mean, but does not preserve the source mean. The available-log mean uses denominator 3,010. A separate zero-filled calculation uses 3,613, assigning 603 invented zeros. The change is a changed dataset and target, not floating-point error. Selected CSVs leave unavailable source fields empty and label zero filling as an invalid processing illustration.
An invalid denominator change for the same source field · displayed decimals rounded
Calculation scope
Available-log mean
Explicit invalid zero-filled mean
1976 supplied trimmed logs
6.261831918
5.216748982
The downloadable Python companion rereads original ZIP fixed-width fields and uses Fraction for exact denominators, sums and means. Base R independently rereads the same original observations. Neither copies numeric answers from case JSON or previous result files. Comparing R floating-point results with exact fractions uses declared tolerances and an additional relative check for small nonzero metrics. Environment records are separate from numeric results and trace actual runtime versions and code/input fingerprints.
Think first, then reveal: Does logging the seven available raw wages restore the missing source logs?
It creates a new transformed variable, not a verified reconstruction of the author’s trimmed logs. Without the source trimming rule these remain different fields. Preserve the original, new field and their availability scopes.
Think first, then reveal: Do identical input hashes and code versions guarantee every last decimal on every machine?
Not always. Runtimes, libraries, operation order and floating-point computation can matter. Separate exact integer/rational invariants from approximations requiring tolerance, and locate a failure in inputs, code or environment. An identical environment also does not establish representativeness.
Store data · What changes if two code-407 records are wrongly collapsed?
The actual New Jersey/Pennsylvania minimum-wage source contains 410 rows with two employment waves. Pair the two waves within the original row. FTE is full-time + 0.5×part-time + managers, computed only when all three required components are available. Calculate a paired change only in the 384 rows with both FTE values, retaining the other 26 rows. This observed change alone is not a policy causal effect without further identification.
There are 409 distinct original store codes. Code 407 occurs in original rows 42 and 168 with different states, chains and wave values. An assertion that original codes must be unique fails on the source. With no evidence that these are erroneous repeats of one real store, do not delete one to force that assumption. source_row_id is a unique positional provenance key within this retained file; it does not certify independent sampling, identity across other files or a permanent longitudinal identifier.
Two actual original-code-407 records · values in FTE
Source row
Original code
State
Chain code
Before
After
Observed change
42
407
PA
2
11
11
0
168
407
NJ
4
12
29/2
5/2
Source preservation versus explicit invalid deletion · means rounded
Processing rule
Source rows kept
Complete pairs
Mean observed change · FTE
Preserve every original row
410
384
-0.070442708
Invalid keep-first code · drop 168
409
383
-0.077154047
Invalid keep-last code · drop 42
409
383
-0.070626632
These are not three firms or policy experiments. They apply declared processing choices to the same source to show the numerical consequence. Invalid deletion examples are public teaching artifacts, not validated cleaning or revised producer vintages. The dependence of the mean on keep-first versus keep-last demonstrates arbitrary-processing sensitivity, not which number identifies a causal effect.
Four of the twelve tests expect a rule to be false: first-page completeness, identical raw/log availability, preservation after filling missing source logs, and uniqueness of original store codes. A test passes when it correctly verifies the expected rejection. Passing an expected-rejection test is the opposite of accepting invalid input. The companions handle expected failures explicitly and leave unexpected failures as execution errors.
Think first, then reveal: Does a failed uniqueness assertion establish a duplicate-source error?
The assertion itself may be unjustified. Check the identifier’s declared scope and other original fields. Here the source supports preserving the two 407 records separately, not asserting an erroneous repeat of one real store.
Think first, then reveal: Why preserve versions, fingerprints and a test report together?
They help distinguish changed input, changed processing and a different runtime when results disagree. Public execution records retain necessary versions and input/code fingerprints, excluding usernames, hosts and secret environment variables. A fixed environment supports traceability; it does not replace valid questions or statistical assumptions.
기초Foundations
48. 공식 문서에서 작은 검사와 표시 설정을 더 읽는다48. Read primary documentation on small tests and display settings
Python 3.11 unittest의 Basic example과 assertEqual·assertIsNone·assertRaises 정의를 읽어 본문의 네 테스트와 연결하세요. 일반 assert 문의 실행 모드 차이는 언어 참조의 해당 항목에서 확인합니다. 문서 페이지의 최신 패치 번호와 실제 실행한 3.11.8은 같은 버전 문자열이라고 쓰지 않습니다.
R은 stopifnot의 참 조건·NA 처리·순차 중단과 options의 digits 항목을 좁게 읽습니다. 오류 처리에는 tryCatch를 직접 둔 본문 예를 따라갑니다. 더 많은 라이브러리 설치 전에 네 작은 입력의 결과부터 손으로 설명해 보세요.
Use the Python 3.11 unittest Basic example and definitions of assertEqual, assertIsNone and assertRaises alongside the four tests. The language reference separately describes ordinary assert execution modes. The documentation’s current patch label is distinct from the executed 3.11.8.
For R, read the scoped stopifnot rules for true conditions, NA and sequential stopping, plus options’ digits entry. The chapter explicitly uses tryCatch when capturing errors. Explain the four small inputs before adding more libraries.
Continue to source meanings, video and assigned case readings through the case links. Review records distinguish primary-text reading, actual program execution and browser playback.
자료 묶음을 풀고 코드와 실제데이터 폴더를 함께 두세요. 터미널에서 코드 파일이 있는 폴더로 이동해 아래 명령을 실행합니다. 코딩이 처음이라면 손계산과 웹 실습을 먼저 하고, 데이터 사이언스 입문에서 코드를 배운 뒤 돌아와도 됩니다.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.
CS50P · 예상한 오류도 검사하기CS50P · Test expected errors too
Harvard CS50P · Week 5 Unit Tests
assert와 실패를 드러내는 예를 먼저 보세요. 이 장의 재현은 Python 표준 unittest와 base R을 쓰며, 영상의 pytest를 설치·실행했다고 가정하지 않습니다.Start with assertions and examples that reveal failures. Our companions use standard unittest and base R; the video’s pytest is not assumed installed or executed.
교재 안의 YouTube 플레이어에서 재생합니다. 원영상에서 제공하는 자막은 플레이어의 CC·설정에서 선택할 수 있습니다.Playback stays in this chapter’s YouTube player. Available captions can be selected through CC/settings.
보고 읽은 뒤 답하기Respond after watching/reading오류가 나야 하는 입력에서 오류를 확인하면 검사가 실패한 건가요?Does confirming an expected error mean a test failed?
생각을 점검하는 해설Check your reasoning
기대한 동작이 거절이라면 그 거절을 확인한 테스트는 통과합니다. 예상하지 못한 오류와 구별합니다.If rejection is the expected behavior, confirming it passes the test. Distinguish unexpected errors.
해들리 위컴 · 계산 도구와 검사의 역할Hadley Wickham · Computational tools and testing
Author’s official page · R Packages book listing
저자의 공식 소개에서 자료 도구와 R Packages의 문서화·검사 주제를 살펴봅니다. 유명한 저자의 도구라도 원자료의 키·단위·결측 계약은 분석자가 확인해야 합니다.Read the author’s introduction to data tools and R Packages on documentation/testing. A well-known tool does not determine the correct source key, unit or missingness contract for an analysis.
보고 읽은 뒤 답하기Respond after watching/reading도구가 자동으로 결측을 처리하면 분석 표적도 자동으로 정해지나요?Does automatic missing-value handling automatically choose a justified target?
생각을 점검하는 해설Check your reasoning
분모·삭제 대상과 질문을 별도로 확인해야 합니다.Check the denominator, removed records and intended question separately.
Python 공식 · assertEqual과 assertRaisesOfficial Python · assertEqual and assertRaises
Python 3.12 documentation · Basic example and assert methods
기본 예제와 assertEqual·assertTrue·assertRaises를 지정해 읽습니다. 문서의 현재 패치 번호와 실제 실행기의 버전은 따로 기록합니다. 테스트는 확인한 조건의 범위에서만 근거를 줍니다.Read the basic example and assertEqual/assertTrue/assertRaises. Record the current documentation patch separately from the actual runtime. Tests supply evidence only within their checked conditions.
보고 읽은 뒤 답하기Respond after watching/reading실제 두 407행을 지우지 않고 어떻게 검사할 수 있나요?How can the two 407 records be tested without deleting either?
생각을 점검하는 해설Check your reasoning
원행 키는 고유함을, 원 코드는 407이 두 번임을 각각 확인합니다. 잘못된 코드 고유성 주장은 예상한 거절로 검사합니다.Verify unique positional source keys and two occurrences of original code 407 separately. Test the unjustified code-uniqueness assertion as an expected rejection.
R 공식 · stopifnot은 모두 TRUE를 요구한다Official R · stopifnot requires all TRUE
R base manual · stopifnot description, details and value
하나라도 TRUE가 아니면 멈추는 조건과 NA를 포함한 경우를 읽습니다. 문서 예제 중 일부는 일부러 오류가 나는 예이며, 실제 R 버전과 문서 버전은 구별합니다.Read the all-TRUE requirement and treatment of NA. Some manual examples deliberately produce errors. Distinguish the actual R runtime from the documentation version.
보고 읽은 뒤 답하기Respond after watching/reading조건이 NA면 TRUE로 검사 통과시켜도 되나요?May an NA condition be treated as passing TRUE?
생각을 점검하는 해설Check your reasoning
확인되지 않은 값을 TRUE로 바꾸지 않습니다. 어떤 필드는 결측이 허용되는지와 유효 값에서만 하는 검사를 명시합니다.Do not turn an unverified condition into TRUE. Declare where unavailability is allowed and which checks apply only to available values.
연습문제 · 계산에서 설명과 증명까지Exercises: calculation, explanation and proof
먼저 혼자 풀고 풀이를 여세요. 숫자와 함께 단위·포함 기준·계산 이유를 확인하세요.Attempt each problem before opening its solution. Check units, inclusion rules and the reason for the calculation.
1. 세 행의 두 분모Two denominators in three rows
설명용 값 목록이 1·결측·3입니다. 원행을 지우지 않고 전체 수, 가용 수, 결측 수, 가용 합과 가용평균을 구하세요. 결측은 관측한 0이 아닙니다.
Toy values are one, missing and three. Retain every row and find total count, available count, missing count, available sum and available mean. Missing is not an observed zero.
풀이와 확인할 이유Solution and explanation
전체 3, 가용 2, 결측 1입니다. 합은 1+3=4이고 가용평균은 4/2=2입니다. 세 행은 모두 보존하면서 평균의 분모는 가용 두 값의 수로 씁니다.
Total three, available two and missing one. Available sum is four and mean is 4/2=2. Retaining all three rows does not require using three as the available-mean denominator.
2. 0을 넣은 별도 표A separate zero-filled table
원자료가 1·결측·3입니다. 결측을 0으로 채운 별도 목록의 평균과 원자료 가용평균을 각각 구하고 차이를 설명하세요.
Original values are one, missing and three. Compute the original available mean and the mean of a separate list in which missing is filled with zero.
풀이와 확인할 이유Solution and explanation
원자료 가용평균은 2입니다. 별도 목록 1·0·3의 평균은 4/3입니다. 합은 같지만 분모가 각각 2와 3이며, 0 대체를 원관측이라고 부르지 않습니다.
The available mean is two. The separate one/zero/three list has mean 4/3. The sum agrees but denominators differ, and the inserted zero is not an original observation.
3. 실제 0과 결측Observed zero versus missing
값 목록이 0·결측·4이고 결측을 허용합니다. 가용 수와 평균을 구하세요. 관측 0까지 빼면 어떤 값이 되나요?
Values are zero, missing and four; missingness is allowed. Find available count and mean. What happens if the observed zero is also removed?
풀이와 확인할 이유Solution and explanation
0은 관측값이므로 가용 수 2, 합 4, 평균 2입니다. 0까지 빼면 가용 수를 1로 잘못 세고 평균 4를 만들게 됩니다.
Zero is observed, so available count is two, sum four and mean two. Removing it incorrectly changes the denominator to one and the mean to four.
4. 잘못된 숫자 글자를 보존Retain invalid numeric text
실습 A 규칙으로 ["0", null, "bad", "-1"]을 검사합니다. 결측 허용·하한 0일 때 전체 수, 비결측 수, 유효 숫자 수와 합·평균 상태를 쓰세요.
Under Lab A rules, check ["0", null, "bad", "-1"] with nullable true and lower bound zero. State total, nonmissing, valid numeric count and sum/mean status.
풀이와 확인할 이유Solution and explanation
전체 4, 비결측 3, 유효 숫자 2입니다. bad는 숫자 읽기 실패이고 −1은 읽을 수 있지만 범위 실패입니다. bad 행을 몰래 빼지 않으므로 전체 수치 합과 평균은 미정의입니다. 원 네 위치를 모두 남깁니다.
Total four, nonmissing three and valid numeric two. bad fails parsing; minus one parses but fails the range. The invalid row is not silently removed, so the full numeric sum and mean are undefined, with all four positions retained.
5. 양끝 포함Inclusive endpoints
허용 범위가 양끝 포함 0–3이고 입력은 0·−1·3·4입니다. 통과하는 값, 범위 실패 수와 이 네 숫자의 평균을 구하세요. 범위 실패 값을 지우지 않습니다.
Bounds zero through three are inclusive. Inputs are zero, minus one, three and four. Identify passing values, count range failures and compute the mean without removing readable failures.
풀이와 확인할 이유Solution and explanation
0과 3이 통과하고 −1과 4가 실패하므로 실패 수는 2입니다. 읽을 수 있는 네 값을 보존한 평균은 (0−1+3+4)/4=3/2입니다. 범위 통과와 수치 요약을 구별합니다.
Zero and three pass; minus one and four fail. There are two range failures. The retained numeric mean is (0−1+3+4)/4=3/2. Range agreement and numeric summarization are separate.
6. 결측 금지로 바꾼 뒤After disallowing missingness
입력 1·결측·3에서 결측 허용을 참에서 거짓으로 바꿉니다. 원행 수·가용 수·가용평균과 계약 판정 중 무엇이 바뀌나요?
For one/missing/three, change nullable from true to false. Which of row count, available count, available mean and contract outcome changes?
풀이와 확인할 이유Solution and explanation
원행 수 3, 가용 수 2, 가용평균 2는 그대로입니다. 결측 행의 상태가 허용 결측에서 결측 금지 실패로 바뀌어 전체 계약은 실패합니다. 원자료 값은 바뀌지 않습니다.
Row count three, available count two and mean two remain. The missing row changes from allowed to disallowed, making the full contract fail. No original value changes.
7. 빈 목록의 세 답Three answers on an empty list
입력이 빈 목록이고 결측을 허용하며 범위 조건도 위반한 행이 없습니다. 빈 합, 가용평균, 행별 조건의 모두 참 결과를 각각 쓰세요.
Input is empty, missingness is allowed and no row violates a range. State the empty sum, available mean and conjunction of row conditions.
풀이와 확인할 이유Solution and explanation
빈 합은 0, 가용평균은 분모 0으로 미정의입니다. 위반 행이 없으므로 행별 조건의 빈 결합은 참일 수 있습니다. 평균 계산 가능성과 조건 결합은 다른 질문입니다.
The empty sum is zero, the mean is undefined and the empty conjunction can be true. Availability of a mean and truth of the condition conjunction are different questions.
8. 자료 실패와 설정 오류Data failure versus configuration error
하한 0에서 관측 −1이 나온 경우와, 하한 3·상한 0을 지정한 경우를 비교하세요. 어느 것이 자료와 규칙의 불일치이고 어느 것이 설정 오류인가요?
Compare observed minus one under lower bound zero with a configuration specifying lower three and upper zero. Classify the failures.
풀이와 확인할 이유Solution and explanation
−1은 올바르게 정한 하한 0을 위반한 자료 조건 실패입니다. 하한 3이 상한 0보다 큰 설정은 허용 구간 자체가 거꾸로여서 설정 오류입니다. 두 경우를 결측으로 바꾸지 않습니다.
Minus one violates a coherently declared data rule. Lower three above upper zero makes the rule configuration invalid. Neither should be converted to missingness.
9. 부재와 명시적 결측Absence versus explicit null
“value 필드가 있어야 하며 그 내용의 결측은 허용한다”는 계약입니다. {"value":null}과 {} 중 어느 기록이 이 계약을 만족하나요?
The contract requires a value field but permits its content to be missing. Which of {"value":null} and {} satisfies it?
풀이와 확인할 이유Solution and explanation
첫 기록은 value 필드가 있고 결측을 허용하므로 만족합니다. 둘째는 필드가 없으므로 실패합니다. 필드 존재 검사와 내용의 결측 허용은 별도입니다.
The first has the required field with permitted missing content. The second lacks the field and fails. Field presence and nullable content are separate rules.
10. 타입을 보존한 키Keys retaining types
실습 B의 타입 보존 규칙으로 키 성분 1, "1", true를 비교합니다. 모두 유효하다면 서로 다른 키는 몇 개인가요?
Under Lab B type-preserving rules, compare key components 1, "1" and true. If all are valid, how many distinct keys are there?
풀이와 확인할 이유Solution and explanation
숫자·문자열·논리값을 구별하므로 3개입니다. 키를 먼저 모두 문자열로 바꾼 다른 규칙과 같은 답을 가정하지 않습니다.
Three: number, string and Boolean differ. Do not assume the same outcome under a separate rule that first converts all keys to text.
11. 구분자 충돌Delimiter collision
조합 ("a|b","c")와 ("a","b|c")의 성분을 세로줄로 단순 연결하면 무엇이 되나요? 성분 보존 조합은 왜 다른가요?
Join the components of ("a|b","c") and ("a","b|c") with vertical bars. Why do component-preserving tuples differ?
풀이와 확인할 이유Solution and explanation
둘 다 a|b|c가 되어 충돌합니다. 성분 보존 목록에서는 첫 칸이 각각 a|b와 a여서 다르며, 역으로 읽을 때 경계가 남습니다.
Both naive joins produce a|b|c. In tuples, the first components remain a|b and a, so component boundaries distinguish the originals.
12. 행 번호와 업무 코드Row positions and business codes
세 기록의 원행 번호는 1·2·3이고 업무 코드는 A·B·B입니다. 각 열의 서로 다른 값 수와 업무 코드의 추가 반복 행 수를 구하세요.
Three records have source-row labels one/two/three and business codes A/B/B. Find the distinct count for each and the additional repeated-row count for the codes.
풀이와 확인할 이유Solution and explanation
원행 번호는 3개, 업무 코드는 2개입니다. 업무 코드의 추가 반복 행은 3−2=1개이며 B 그룹에는 두 원행이 있습니다. 이것만으로 한 행을 삭제할 근거는 아닙니다.
Source-row labels have three distinct values; codes have two. There is one additional repeated row, with two rows in the B group. This does not justify deleting either.
13. 결측 키를 허용한 반복Repeated permitted null keys
두 기록의 id 필드가 모두 명시적 null입니다. 실습 B에서 null 키를 허용하고 id만 키로 쓰면 유효성·고유성은 어떻게 되나요?
Two records both contain an explicit null id. In Lab B, permit null keys and use only id. What are validity and uniqueness?
풀이와 확인할 이유Solution and explanation
두 키는 모두 유효하지만 같은 null 성분이므로 반복입니다. 유효 키 수 2·서로 다른 유효 키 수 1이고 전체 고유성은 실패합니다.
Both keys are valid but repeat the same null component. There are two valid key rows and one distinct valid key, so full uniqueness fails.
14. 유효 키만 고유한 경우Uniqueness only among valid keys
세 행 중 한 행에는 유효한 키 A가 있고 나머지 두 행에는 필수 키 필드가 없습니다. 유효 키들끼리 고유하다는 말과 모든 행의 키가 유효하고 고유하다는 말의 진릿값을 쓰세요.
One of three records has valid key A; two lack the required key field. Evaluate uniqueness among valid keys and validity-plus-uniqueness for all rows.
풀이와 확인할 이유Solution and explanation
유효 키가 A 하나이므로 유효 키들끼리 고유하다는 말은 참입니다. 두 행이 필드 부재로 실패하므로 전체 유효·고유 계약은 거짓입니다.
The single valid key is unique among valid keys. The full contract fails because two records lack their required key field.
15. 빈 수집의 고유성과 완전성Empty collection: unique versus complete
필요한 연도 키가 여섯 개인데 받은 행은 0개입니다. 키가 반복되지 않는다는 조건과 여섯 키를 모두 받았다는 조건을 각각 판정하세요.
Six annual keys are required but zero rows were received. Evaluate no repeated keys and complete receipt of all six keys.
풀이와 확인할 이유Solution and explanation
반복 키가 없다는 조건은 참이지만 완전성은 실패합니다. 고유 수 0은 필요한 수 6과 다르므로 빈 수집을 완전 수집으로 부를 수 없습니다.
No key repeats, but completeness fails: distinct count zero differs from required six. An empty collection is not complete.
16. 출력끼리의 관계만 맞는 오류An internally consistent wrong output
실제 입력이 1·결측·3인데 프로그램이 가용 수 3·합 6·평균 2를 냈습니다. 합=가용 수×평균은 맞나요? 이 결과 전체가 올바른가요?
For actual input one/missing/three, a program reports available count three, sum six and mean two. Does sum=count×mean hold, and is the output correct?
풀이와 확인할 이유Solution and explanation
6=3×2는 맞습니다. 그러나 실제 가용 수는 2이고 합은 4입니다. 출력끼리의 관계 하나가 맞아도 입력과의 직접 비교는 실패합니다.
The identity 6=3×2 holds. Yet the actual available count is two and sum four. Internal consistency alone does not establish agreement with the input.
17. 틀린 기대 원행 수Wrong expected row count
입력 1·결측·3에 기대 원행 수 4·가용 수 2·합 4·평균 2를 줍니다. 네 조건 중 몇 개가 통과하고 전체 결합은 무엇인가요?
For one/missing/three, expect total four, available two, sum four and mean two. How many conditions pass and what is their conjunction?
풀이와 확인할 이유Solution and explanation
가용 수·합·평균의 세 조건이 통과하고 원행 수 조건이 실패합니다. 전체 결합은 거짓입니다. 기대를 맞추려고 네 번째 가짜 행을 만들지 않습니다.
Three pass; expected total four fails against actual three. The conjunction is false. Do not invent a fourth row to satisfy the expectation.
18. 기대 조건이 하나도 없을 때No supplied expectations
실습 C에 기대 조건 객체 {}를 줍니다. 빈 결합이 참이라는 결과가 무엇을 뜻하며 무엇을 뜻하지 않나요?
Lab C receives the empty expectation object {}. What does a true empty conjunction mean?
풀이와 확인할 이유Solution and explanation
비교한 기대 조건이 0개라 반례가 없는 빈 결합이라는 뜻입니다. 필요한 행·단위·평균이 실제로 맞다는 구체적 검사를 수행했다는 뜻은 아닙니다.
Zero expected conditions were compared, leaving no counterexample to the empty conjunction. It does not report substantive checks of required rows, units or means.
19. 정확 분수의 작은 차이A small exact fraction difference
정확한 1/3과 정확 소수 0.333333을 비교합니다. 차이를 분수로 구하고 하한 1/3 이상 조건을 각각 판정하세요.
Compare exact 1/3 with exact decimal 0.333333. Find the fraction difference and evaluate a lower bound of at least 1/3.
풀이와 확인할 이유Solution and explanation
차이는 1/3−333333/1000000=1/3000000입니다. 1/3은 경계에서 통과하고 0.333333은 더 작으므로 실패합니다. 표시를 같은 네 자리로 반올림해 판정하지 않습니다.
The difference is 1/3000000. Exact 1/3 passes at the boundary; 0.333333 is smaller and fails. Equal short rounded displays do not determine the exact check.
20. 절대 허용 오차Absolute tolerance
유한한 비교값 a=100,b=100.000001이고 절대 허용 오차가 0.000002, 상대 허용 오차가 0입니다. |a−b|≤허용 오차를 판정하세요.
Finite values are a=100 and b=100.000001, with absolute tolerance 0.000002 and relative tolerance zero. Evaluate the comparison.
풀이와 확인할 이유Solution and explanation
차이는 0.000001로 0.000002 이하이므로 통과합니다. 값이 달러라면 이 절대 허용 오차도 달러입니다.
Difference 0.000001 is at most 0.000002, so it passes. If the values are dollars, the absolute tolerance is also in dollars.
21. 상대 허용 오차Relative tolerance
비교 규칙이 |a−b|≤ε_rel max(|a|,|b|)이고 a=1000000,b=1000001,ε_rel=1/1000000입니다. 절대 항은 0입니다. 판정과 오른쪽 한계를 구하세요.
Use |a−b|≤ε_rel max(|a|,|b|) with a=1000000, b=1000001 and ε_rel=1/1000000. The absolute term is zero. Find the limit and outcome.
풀이와 확인할 이유Solution and explanation
차이는 1이고 오른쪽 한계는 1000001/1000000=1.000001입니다. 따라서 통과합니다. 이 상대 항은 값의 규모에 비례합니다.
The difference is one and the limit is 1.000001, so it passes. The relative term scales with the comparison magnitude.
22. 단위가 다르면 먼저 환산Convert units before numerical comparison
548센트/시간과 5.48달러/시간을 수치 548과 5.48만으로 비교하려고 합니다. 큰 허용 오차를 정하기 전에 무엇을 해야 하나요?
Compare 548 cents per hour with 5.48 dollars per hour. What should precede choosing a large tolerance for bare numbers 548 and 5.48?
풀이와 확인할 이유Solution and explanation
같은 단위로 환산합니다. 548센트/시간은 5.48달러/시간이므로 100으로 나누어 비교할 수 있습니다. 단위가 다른 수를 큰 오차로 통과시키는 방식은 같은 의미의 비교가 아닙니다.
Convert to a common unit: 548 cents per hour equals 5.48 dollars per hour. A large tolerance on unlike units is not a meaningful substitute.
23. 세 구현의 첫 출력First output from three implementations
입력은 1·결측·3입니다. 가용평균, 전체 수로 나눈 0 채움 평균, 첫 가용값 구현의 출력을 각각 구하세요.
For one/missing/three, compute outputs from the available mean, zero-filled mean using total count and first-available implementation.
풀이와 확인할 이유Solution and explanation
각각 2,4/3,1입니다. 이 입력 하나가 세 구현을 구별합니다.
They return two, 4/3 and one, respectively. This input distinguishes the three implementations.
24. 우연히 버그를 놓치는 입력A case that misses a bug by coincidence
첫 가용값을 평균이라고 반환하는 구현을 2·결측·2로 시험하면 왜 통과할 수 있나요? 다른 두 가용값을 써서 실패 사례를 제시하세요.
Why can a first-available implementation pass a mean test on two/missing/two? Supply a failing case with unequal available values.
풀이와 확인할 이유Solution and explanation
첫 값 2가 실제 평균 2와 같기 때문입니다. 예를 들어 1·결측·3에서는 실제 평균 2인데 구현은 1을 반환하므로 실패합니다.
The first value two happens to equal the mean. One/missing/three has true mean two but the implementation returns one, exposing the bug.
25. 네 테스트의 두 실패Two failures in four tests
기대가 1·결측·3→2, 결측 한 칸→미정의, 빈 목록→미정의, bad→숫자 오류인 네 테스트입니다. 0 채움 구현은 비어 있지 않은 목록에서 가용 합을 전체 수로 나누고, 빈 목록은 미정의, bad는 숫자 오류를 냅니다. 통과·실패 수를 구하세요.
Four expectations are one/missing/three→two, one missing→undefined, empty→undefined, bad→numeric error. A zero-filled implementation divides available sum by total nonempty length, returns undefined for empty and raises the numeric error for bad. Count outcomes.
풀이와 확인할 이유Solution and explanation
첫 입력은 4/3으로 실패, 둘째는 0으로 실패입니다. 빈 목록과 기대 숫자 오류는 통과합니다. 총 4개 중 2통과·2실패입니다.
The first returns 4/3 and fails; the second returns zero and fails. Empty input and the expected numeric error pass. Two of four pass and two fail.
26. 다른 오류를 성공으로 세지 않기Do not accept an unrelated error
숫자 읽기 오류 코드 invalid-numeric-value를 기대한 테스트에서 실제로 file-not-found 오류가 나왔습니다. 오류가 있었다는 이유만으로 통과시켜도 되나요?
A test expects numeric error code invalid-numeric-value but observes file-not-found. Does the presence of an error suffice to pass?
풀이와 확인할 이유Solution and explanation
아닙니다. 기대 종류가 오류라는 점만 같고 오류 코드가 다릅니다. 입력 파일 문제를 숫자 읽기 규칙의 정상 거절과 구별해야 하므로 이 기대는 충족되지 않았습니다.
No. The error kind matches but the code does not. A missing-file failure is not confirmation of the declared numeric rejection.
27. Python의 세 비교 방법Three Python test methods
Python unittest에서 기대값 2, 기대 미정의 None, 기대 ValueError를 각각 확인할 때 본문에 사용한 메서드 이름을 쓰세요.
Name the unittest methods used to check expected value two, expected None and expected ValueError.
풀이와 확인할 이유Solution and explanation
assertEqual, assertIsNone, assertRaises입니다. 숫자 오류를 기대한 테스트는 그 오류를 확인하면 통과할 수 있습니다.
assertEqual, assertIsNone and assertRaises. Confirming a declared expected error can be a successful test.
28. 일반 assert의 실행 모드Ordinary assert execution mode
Python 코드의 자료 검사를 일반 assert 문 하나에만 맡겼습니다. 최적화 옵션 -O를 사용하면 어떤 문제가 있나요? 이 장의 실제 네 테스트 실행은 무엇을 사용했나요?
A data check relies only on an ordinary Python assert statement. What changes under -O, and what did the chapter four-case runs use?
풀이와 확인할 이유Solution and explanation
일반 assert 문은 최적화 실행에서 제거될 수 있어 필수 자료 검증을 수행했다는 근거가 되지 못할 수 있습니다. 실제 네 테스트 기록은 최적화 옵션 없이 unittest의 비교 메서드와 결과 보고를 사용했습니다.
Ordinary assertions can be omitted under optimization, so a mandatory validation may not execute. The fixed four-case runs used unittest methods and reports without the optimization flag.
29. R 조건 안의 NANA inside an R condition
base R에서 stopifnot(c(TRUE, NA))를 실행하면 모두 참 조건을 만족하나요? NA를 관측한 0이나 거짓과 같은 자료값으로 바꾸어도 되나요?
Does stopifnot(c(TRUE, NA)) satisfy the all-true condition in base R? Should NA be replaced by observed zero?
풀이와 확인할 이유Solution and explanation
모두 참이 아니므로 오류로 멈춥니다. NA는 불명인 논리 상태이며 자료의 0으로 바꾸지 않습니다. 필요한 결측 규칙과 기대 결과를 따로 정합니다.
It does not satisfy all true and stops with an error. NA is an unknown logical state, not an observed zero. Specify the missingness rule and expectation separately.
30. R의 결과 수집 순서Order of collecting R test outcomes
네 테스트 중 첫 두 개가 실패합니다. 첫 실패에서 바로 stopifnot으로 중단하는 방식과, 네 판정을 먼저 수집한 뒤 stopifnot(all(passed)) 하는 방식을 비교하세요.
The first two of four cases fail. Compare stopping immediately with collecting all four case outcomes before stopifnot(all(passed)).
풀이와 확인할 이유Solution and explanation
첫 방식은 뒤 사례를 실행하지 못할 수 있습니다. 둘째는 네 사례를 각각 오류 처리와 함께 계산한 뒤 판정 목록을 남기고 전체 실패로 종료할 수 있습니다. 이번 고정 R 묶음은 둘째 방식으로 실제 두 실패를 보존했습니다.
Immediate stopping can leave later cases unexecuted. Collecting each case with explicit error handling retains all outcomes before the nonzero suite exit. The fixed R suite preserves both failures this way.
가용값 1과 3을 첫 가용값 구현에 순서대로 넣으면 1이고, 순서를 뒤집으면 3입니다. 실제 평균은 두 경우 모두 얼마이며, 어떤 관계 검사가 이 버그를 잡나요?
A first-available implementation returns one on [1,3] and three on [3,1]. What is the true mean in each, and which property exposes the bug?
풀이와 확인할 이유Solution and explanation
실제 평균은 두 경우 모두 2입니다. 평균의 순열 불변 관계가 첫 가용값 구현의 1과 3 차이를 드러냅니다.
Both true means are two. Permutation invariance of the mean exposes the differing first-available outputs.
32. 아핀 변환의 평균Mean under an affine transformation
유한한 두 가용값이 1과 3입니다. 각각을 5+2x로 바꾼 새 값과 새 평균을 구하고, 원평균을 이용해 검산하세요.
Finite available values are one and three. Transform each to 5+2x, compute the new values and mean, and check using the original mean.
풀이와 확인할 이유Solution and explanation
새 값은 7과 11, 평균은 9입니다. 원평균 2에 5+2×2를 적용해도 9가 되어 일치합니다.
The values become seven and eleven, with mean nine. Applying 5+2×2 to the original mean also gives nine.
33. 음수 배율과 범위A negative scale changes bound order
원값 x의 허용 범위가 양끝 포함 0≤x≤3입니다. y=−2x로 바꾸면 대응 허용 범위는 무엇인가요? 원 상한에 −2를 곱한 −6을 새 상한이라고 하면 왜 틀리나요?
Original bounds are inclusive 0≤x≤3. For y=−2x, find corresponding bounds and explain why minus six is not the new upper bound.
풀이와 확인할 이유Solution and explanation
범위는 −6≤y≤0입니다. 음수를 곱하면 부등호 방향이 바뀌므로 −6은 새 하한입니다. 값 변환과 함께 범위 계약도 같은 의미로 바꿔야 합니다.
The range is −6≤y≤0. Multiplication by a negative reverses inequality order. Transform the contract consistently with the values.
34. 이동 관계만으로 평균을 확인할 수 있나Shift equivariance alone is insufficient
첫 가용값만 반환하는 함수에 유한한 비어 있지 않은 값 목록을 넣습니다. 모든 값에 a를 더하면 출력도 a만큼 커집니다. 이 성질이 그 함수가 평균이라는 증명인가요?
A first-available function on a nonempty finite list shifts its output by a when a is added to every value. Does this property prove it is a mean?
풀이와 확인할 이유Solution and explanation
아닙니다. 첫 가용값 함수가 그 이동 관계를 만족한다는 반례가 이미 주어졌습니다. [1,3]의 출력은 1로 실제 평균 2와 다릅니다. 다른 기대값·순열 사례가 필요합니다.
No. This function itself is a counterexample: it respects shifts but returns one on [1,3], whose mean is two. Include other expectations and permutation cases.
35. 바이트와 의미의 차이Bytes versus numeric meaning
파일 A의 숫자 원문은 1이고 파일 B는 1.0입니다. 원바이트가 다르지만 이 장의 정확 숫자 해석은 같을 수 있나요? 해시 비교와 값 비교를 나누어 설명하세요.
File A contains numeric text 1 and file B 1.0. Can they differ in bytes but agree under exact numeric interpretation?
풀이와 확인할 이유Solution and explanation
둘 다 정확 수 1로 읽히므로 숫자 값은 같습니다. 원문 바이트는 다르므로 원문 동일 여부는 별도이며 해시가 다를 수 있습니다. 숫자 해석이 같다는 사실을 바이트가 같다는 말로 바꾸지 않습니다.
Both can represent exact one. Original-byte identity is separate, and their hashes can differ. Equal parsed values do not imply identical bytes.
36. 환경 기록의 타입Types in environment metadata
실습 E에서 기대 RDigits는 숫자 17인데 현재 기록은 문자열 "17"입니다. 타입을 보존하는 비교에서 통과하나요?
Lab E expects numeric RDigits seventeen but receives string "17". Does type-sensitive comparison pass?
풀이와 확인할 이유Solution and explanation
통과하지 않습니다. 수치 17과 문자열 17은 타입이 다릅니다. 자동 강제 변환이 필요하다면 그 변환 규칙을 별도로 선언해야 합니다.
No. Numeric seventeen and string seventeen differ in type. Any intended coercion requires a separately declared rule.
37. 필수 환경 필드A required environment field
기대 객체가 {"TZ":"UTC"}이고 TZ가 필수입니다. 현재 객체 {}와 {"TZ":null}을 각각 판정하고 차이를 설명하세요.
Expected object is {"TZ":"UTC"} with required TZ. Evaluate actual {} and {"TZ":null}.
풀이와 확인할 이유Solution and explanation
둘 다 기대 UTC와 일치하지 않아 실패합니다. 첫째는 필수 필드 부재, 둘째는 존재하는 필드의 값 불일치입니다. 없는 값을 자동 UTC로 채우지 않습니다.
Both fail agreement with UTC. One lacks the field; the other has a mismatching explicit null. Neither is automatically filled with UTC.
38. 객체 순서와 배열 순서Object order and array order
실습 E는 객체 필드 나열 순서를 무시하고 배열 순서를 보존합니다. {"a":1,"b":2}와 {"b":2,"a":1}, 그리고 [1,2]와 [2,1]의 비교 결과를 쓰세요.
Lab E ignores object-field order but retains array order. Compare {"a":1,"b":2} with {"b":2,"a":1}, and [1,2] with [2,1].
풀이와 확인할 이유Solution and explanation
두 객체는 같은 타입·필드값으로 일치합니다. 두 배열은 원소 순서가 달라 불일치입니다. 어느 순서가 의미를 가지는지 비교 규칙에 명시합니다.
The objects agree by typed field values. The arrays disagree because their element order differs. The comparison rule must state which order matters.
39. 두 표시 문자열Two formatted strings
한 번 계산한 수치 1/3을 0.3333333과 0.33333333333333331로 형식화했습니다. 문자열 차이만으로 계산값이 달라졌다고 결론 내려도 되나요?
One computed numerical 1/3 is formatted as 0.3333333 and 0.33333333333333331. Does the string difference establish different computed values?
풀이와 확인할 이유Solution and explanation
안 됩니다. 같은 내부 수를 두 형식으로 인쇄한 경우입니다. 원값과 표시 설정을 함께 비교해야 하며, 더 긴 문자열이 수학적 1/3을 유한 십진수로 정확히 표현한 것도 아닙니다.
No. The same internal number was formatted twice. Compare values and settings separately; the longer finite decimal is not an exact representation of mathematical 1/3 either.
40. 실행과 그림 개수Counts of executions and plots
총 32개 실제 실행에서 의도적 비영 종료 2개, 성공 종료 30개입니다. 성공 중 환경 텍스트 전용이 4개이고 나머지는 그림을 하나씩 만듭니다. 그림 수와 그림 없는 실행 수를 구하세요.
Thirty-two actual runs include two deliberate nonzero exits and thirty successful exits. Four successful environment runs are text-only; each remaining success makes one plot. Count plots and runs without plots.
풀이와 확인할 이유Solution and explanation
그림은 30−4=26개입니다. 그림 없는 실행은 의도적 실패 2개와 환경 4개를 합한 6개입니다. 26+6=32로 전체 실행 수와 맞습니다.
There are twenty-six plots and six runs without plots: two deliberate failures plus four environment runs. Twenty-six plus six equals thirty-two.
41. 0 채움 관계와 일치 조건Zero-filling identity and equality condition
유한한 N개 원행 중 n개가 가용이고 1≤n≤N입니다. 가용 합은 S입니다. 나머지를 모두 0으로 채웠을 때 평균과 가용평균의 관계를 증명하고, 두 평균이 같을 필요충분조건을 쓰세요.
Among N finite source rows, n are available with 1≤n≤N and sum S. Prove the relation between the available mean and the mean after filling the rest with zero; give the necessary and sufficient equality condition.
풀이와 확인할 이유Solution and explanation
가용평균은 S/n, 0 채움 평균은 S/N입니다. 아래 차이가 0일 조건을 읽으면 됩니다.
They agree exactly when n=N or the available mean is zero. The premise excludes n=0, where the available mean is undefined.
42. 합과 평균이 같아도 다른 자료Equal summaries, different data
두 유한 값 목록 [1,3]과 [0,4]를 비교하세요. 개수·합·평균 검사만으로 원값 목록이 같다고 확인할 수 있나요?
Compare finite lists [1,3] and [0,4]. Can count, sum and mean checks establish identical original values?
풀이와 확인할 이유Solution and explanation
두 목록은 모두 개수 2·합 4·평균 2이지만 값은 다릅니다. 예를 들어 최솟값은 1과 0입니다. 이 세 요약 검사를 원행·전체값 동일성 검사로 부를 수 없습니다.
Both have count two, sum four and mean two, but different values and minima. The three summary checks do not establish row/value identity.
43. 가용 수로 가중한 결합 평균A combined mean weighted by available counts
겹치지 않는 두 집단의 유한 가용값이 [1,3]과 [10]입니다. 집단 평균의 단순 평균과 전체 가용평균을 구하고 올바른 가중식을 쓰세요.
Two disjoint groups have finite available values [1,3] and [10]. Find the unweighted average of group means and the full mean, then give the correct weights.
풀이와 확인할 이유Solution and explanation
집단 평균은 2와 10으로 단순 평균은 6입니다. 전체는 (1+3+10)/3=14/3이며, (2/3)×2+(1/3)×10과 같습니다. 가중치는 집단 가용 수를 전체 가용 수로 나눈 값입니다.
Group means two and ten average to six. The full mean is 14/3=(2/3)×2+(1/3)×10. Weights use available group counts over total available count.
44. 모든 값에서 평균을 보존하는 반복수Multiplicities preserving every possible mean
N≥1개 유한 실수 xᵢ를 각각 비음수 정수 mᵢ번 반복합니다. M=Σmᵢ>0입니다. 반복 평균이 원래 균등 평균과 모든 값 벡터에서 같을 필요충분조건을 증명하세요.
Repeat each of N≥1 finite real values xᵢ a nonnegative integer mᵢ times, with M=Σmᵢ>0. Prove the necessary and sufficient condition for the repeated mean to equal the original uniform mean for every value vector.
풀이와 확인할 이유Solution and explanation
조건은 모든 mᵢ가 같은 양의 정수인 것입니다. 필요성은 j번째 값만 1이고 나머지는 0인 벡터를 넣어 mⱼ/M=1/N을 모든 j에서 얻으면 됩니다. 따라서 mⱼ=M/N으로 같습니다. 반대로 모두 같은 양수 c이면 분자·분모의 c가 약분되어 원평균입니다.
All multiplicities must be the same positive integer. For necessity, set only coordinate j to one, giving mⱼ/M=1/N for every j. Thus all equal M/N. Conversely, a common positive multiplicity cancels from numerator and denominator.
45. 복원 가능한 키 표현의 증명Proof for a recoverable key representation
키 표현 E와 복원 함수 D가 모든 허용 원키 k에서 D(E(k))=k를 만족합니다. E(k₁)=E(k₂)이면 k₁=k₂임을 증명하세요.
An encoding E and decoder D satisfy D(E(k))=k for every allowed key. Prove E(k₁)=E(k₂) implies k₁=k₂.
풀이와 확인할 이유Solution and explanation
같은 표현 양쪽에 D를 적용하면 D(E(k₁))=D(E(k₂))입니다. 복원 전제에 의해 왼쪽은 k₁, 오른쪽은 k₂이므로 같습니다. 이 전제는 구분자 단순 연결처럼 복원이 모호한 표현에는 성립하지 않을 수 있습니다.
Apply D to both sides and use the recovery premise. The results are k₁ and k₂, hence equal. Ambiguous delimiter concatenation need not satisfy the premise.
46. 해시만으로 모든 키를 구별할 수 있나Can a hash distinguish every possible key?
출력이 256비트인 해시를 모든 33바이트 입력에 적용합니다. 입력 수와 출력 수를 비교해 서로 다른 입력의 같은 출력이 반드시 존재함을 설명하세요. 실제 충돌을 찾았다고 주장해야 하나요?
Apply a 256-bit-output hash to every 33-byte input. Compare cardinalities to show some different inputs share an output. Does this find an actual collision pair?
풀이와 확인할 이유Solution and explanation
입력은 2²⁶⁴개, 출력은 최대 2²⁵⁶개입니다. 유한 비둘기집 원리에 의해 어떤 서로 다른 두 입력은 같은 출력을 가집니다. 존재 증명이며 실제 충돌 쌍을 계산했다는 주장은 아닙니다.
There are 2²⁶⁴ inputs but at most 2²⁵⁶ outputs, so the finite pigeonhole principle guarantees a collision. This is an existence argument, not computation of a particular pair.
47. 독립 두 테스트의 발견 확률Detection in two independent random tests
가정한 입력 추출 법칙에서 한 입력이 버그를 드러낼 확률은 1/4입니다. 같은 법칙에서 독립·복원으로 두 번 뽑으면 적어도 한 번 발견할 확률은 얼마인가요?
Under a declared input law, one draw exposes a bug with probability 1/4. Two draws are independent with replacement from that law. Find probability of at least one detection.
풀이와 확인할 이유Solution and explanation
한 번도 발견하지 않을 확률은 (3/4)²=9/16이므로 발견 확률은 7/16입니다. 고정한 네 수업 테스트에 이 추출 법칙을 자동으로 적용하지 않습니다.
No detection has probability 9/16, so detection has probability 7/16. This sampling law does not automatically apply to the chapter fixed cases.
48. 같은 임의 입력을 두 번 재사용Reusing one random input twice
한 번 임의로 뽑은 입력이 버그를 드러낼 확률은 1/4입니다. 그 동일 입력을 결정적인 같은 구현에 두 번 적용합니다. 적어도 한 번 발견할 확률이 7/16인가요?
A single randomly drawn input exposes a bug with probability 1/4. Apply that identical input twice to the same deterministic implementation. Is detection probability 7/16?
풀이와 확인할 이유Solution and explanation
아닙니다. 두 판정은 같아 둘 다 발견하거나 둘 다 놓칩니다. 발견 확률은 1/4입니다. 두 번 실행했다는 개수만으로 독립 추출 가정을 만들 수 없습니다.
No. Both outcomes agree, so detection probability remains 1/4. Two executions do not create two independent input draws.
49. 가정한 무작위 테스트 수A count under an assumed random-test law
독립·복원 입력 추출을 가정하고 각 입력의 버그 발견 확률이 최소 1/10입니다. 적어도 한 번 발견할 확률을 0.95 이상으로 만들 최소 양의 정수 m을 구하세요. 이는 실제 고정 사례의 성능 보장이 아니라 주어진 추출 법칙의 계산입니다.
Assume independent input draws with replacement, each detecting a bug with probability at least 1/10. Find the smallest positive m guaranteeing detection probability at least 0.95 under these assumptions.
풀이와 확인할 이유Solution and explanation
발견 못할 확률의 상한은 (9/10)^m입니다. 이것이 1/20 이하가 되도록 정합니다. (9/10)²⁸≈0.052335>0.05, (9/10)²⁹≈0.047101<0.05이므로 최소 29입니다. 발견 확률이 정확히 1/10인 허용 법칙이 있어 더 작은 수로 일반 보장할 수 없습니다.
The no-detection bound is (9/10)^m. Its values at twenty-eight and twenty-nine are about 0.052335 and 0.047101. Thus twenty-nine is minimal. An allowed law with detection exactly 1/10 shows a smaller count cannot give the general guarantee.
50. 네 통과가 모든 입력을 증명하지 못하는 반례Four passes do not prove all-input correctness
기대가 [1,결측,3]→2, [결측]→미정의, []→미정의, [bad]→숫자 오류인 네 사례입니다. 이 네 개는 맞추면서 다른 입력 하나에서는 틀리는 함수를 설명하세요.
Four expectations are [1,missing,3]→two, [missing]→undefined, []→undefined and [bad]→numeric error. Describe a function passing all four but wrong on another input.
풀이와 확인할 이유Solution and explanation
정상 가용평균을 계산하되 입력이 정확히 [2,4]일 때만 99를 반환하도록 만든 함수를 생각할 수 있습니다. 네 지정 입력에는 [2,4]가 없어 모두 통과하지만 그 입력의 참평균 3과 다릅니다. 사례 통과와 모든 입력 정당성은 다릅니다.
Use the correct available mean except return ninety-nine exactly on [2,4]. That input is absent from the four cases, yet its true mean is three. The selected passes do not prove all-input correctness.
51. 실제 여섯 연도와 첫 페이지Actual six years versus the first page
한국 GDP 지표의 필요한 키는 2019–2024 여섯 연도입니다. 실제 첫 페이지에는 2022·2023·2024만 있고 모두 고유·가용합니다. 고유성·가용성·여섯 키 완전성을 각각 판정하세요.
Required Korean GDP keys cover 2019–2024. The actual first page contains only 2022/2023/2024, all unique and available. Evaluate uniqueness, availability and six-key completeness.
풀이와 확인할 이유Solution and explanation
현재 세 키의 고유성과 값 가용성은 통과합니다. 완전성은 2019·2020·2021 세 키가 없어 실패합니다. 원페이지를 보존하고 둘째 페이지와 연결해야 여섯 키 범위를 확인할 수 있습니다.
Uniqueness and availability pass on the received three keys. Completeness fails because 2019/2020/2021 are absent. Retain page identity and combine the second page to check all six.
52. 실제 원시급의 분모Denominator for actual raw wages
실제 개인 원행은 3,613개이고 원시급 가용 수는 3,017, 가용 합은 1,738,060센트/시간입니다. 결측 수와 가용평균·별도 0 채움 평균을 정확 분수로 구하세요.
There are 3,613 person rows, 3,017 available raw wages and available sum 1,738,060 cents per hour. Find missing count and exact available/zero-filled means.
풀이와 확인할 이유Solution and explanation
결측은 3,613−3,017=596개입니다. 가용평균은 1,738,060/3,017센트/시간, 0 채움 평균은 1,738,060/3,613센트/시간입니다. 원자료를 바꾸지 않고 두 정의를 나누어 보고합니다.
Missing count is 596. The means are 1,738,060/3,017 and 1,738,060/3,613 cents per hour. Report their separate definitions without changing the original source.
53. 가용 수 차이만으로 일곱 행을 알 수 있나Do count differences identify exactly seven rows?
같은 3,613행에서 원시급 가용 수 3,017·원 로그 가용 수 3,010이라는 개수만 압니다. 이 정보만으로 “원시급만 가용한 행이 정확히 7개”를 증명할 수 있나요? 두 가용 집합의 교집합 크기 범위도 구하세요.
On the same 3,613 rows, only raw-wage availability 3,017 and source-log availability 3,010 are known. Do these counts alone prove exactly seven raw-only rows? Bound their intersection size.
풀이와 확인할 이유Solution and explanation
개수만으로는 안 됩니다. 교집합 I는 3,017+3,010−3,613=2,414 이상, 3,010 이하입니다. 원시급만 가용한 수 3,017−I는 7–603 범위입니다. 실제 자료에서는 원행을 직접 대조해 그 수가 7이고 원 로그만 가용한 행은 0임을 확인한 것입니다.
No. Intersection I ranges from 2,414 to 3,010, so raw-only count 3,017−I ranges from seven to 603. The actual source-row comparison, not counts alone, establishes seven raw-only and zero log-only records.
54. 일곱 실제 차이 행의 의미Meaning of the seven actual differing rows
원행 712·813·1180·1423·1807·3091·3301은 실제 원시급이 있지만 원문 절단 로그가 없습니다. 이 관찰에서 원 로그의 절단 규칙 전체를 복원했다고 결론 내려도 되나요?
Actual source rows 712/813/1180/1423/1807/3091/3301 have raw wage but no source-trimmed log. Does this reconstruct the entire source trimming rule?
풀이와 확인할 이유Solution and explanation
안 됩니다. 일곱 행의 필드 가용성 차이를 직접 확인한 것입니다. 처리 규칙을 추론하려면 별도 문서·원변환 절차가 필요하며, 지금은 두 원필드와 결측 상태를 보존해 보고합니다.
No. It establishes observed availability differences on those rows. Reconstructing the procedure requires other documentation or transformation evidence; preserve the two supplied fields and missing flags.
55. 410행과 409코드410 rows and 409 codes
410개 원행의 코드가 모두 존재하며 서로 다른 코드는 409개입니다. 반복 코드의 추가 행 수는 얼마인가요? 이것만으로 실제 중복 입력이라고 결론 내릴 수 있나요? 실제 코드 407의 원행 42·168은 서로 다른 필드를 가집니다.
All 410 source rows have a code, with 409 distinct codes. Find the additional repeated-row count. Does that establish a duplicate entry? Actual code 407 rows 42/168 have different fields.
풀이와 확인할 이유Solution and explanation
추가 반복 행은 410−409=1개입니다. 이 수만으로 같은 실제 점포의 이중 입력인지 알 수 없습니다. 원행 42·168의 주·체인·FTE를 보존하고 코드 반복과 기록 동일성을 구별합니다.
There is one additional repeated row. This alone does not establish duplicated real-world identity. Retain both records and distinguish repeated codes from identical records.
56. 실제 두 삭제 대비Two actual deletion contrasts
실제 완전짝 384개의 변화 합은 −541/20FTE입니다. 원행 42의 변화는 0, 원행 168의 변화는 5/2입니다. 보존·42 삭제·168 삭제의 평균을 각각 정확 분수로 구하세요. 삭제는 비교용 가정이며 원본은 보존합니다.
The 384 complete-pair changes sum to −541/20 FTE. Row 42 has change zero; row 168 has 5/2. Find exact means for retention, hypothetical deletion 42 and deletion 168, while preserving the original.
풀이와 확인할 이유Solution and explanation
보존은 (−541/20)/384=−541/7680입니다. 42 삭제는 (−541/20)/383=−541/7660입니다. 168 삭제는 (−541/20−5/2)/383=−591/7660입니다. 각각의 분자와 분모를 함께 바꿉니다.
They are −541/7680, −541/7660 and −591/7660. The last numerator uses −541/20−5/2=−591/20, with 383 retained complete pairs.
57. 0 변화 행을 빼도 평균은 달라질 수 있다Deleting a zero can change the mean
유한한 n≥2개 값의 합이 S이고 그중 한 값은 0입니다. 그 0을 삭제한 평균과 원평균이 같을 필요충분조건을 구하세요.
A finite list of n≥2 values has sum S and includes one zero. Find the necessary and sufficient condition for deleting that zero to preserve its mean.
풀이와 확인할 이유Solution and explanation
원평균 S/n과 삭제 평균 S/(n−1)의 차이는 S/[n(n−1)]입니다. 따라서 S=0일 때 그리고 그때에만 같습니다. 값 0 삭제가 평균에 영향이 없다는 일반 주장은 틀립니다.
The difference S/(n−1)−S/n is S/[n(n−1)]. Equality therefore holds exactly when S=0. A zero-valued record need not have zero effect on a mean denominator.
58. 두 단계 계약의 합성Composition of two contracted stages
전제 P에서 함수 f가 Q를 만족하는 값을 반환하고, Q인 입력에서 함수 g가 R을 보장합니다. 같은 반환값을 g에 넘기고 두 함수가 정상 종료할 때 결론은 무엇인가요? 오래된 다른 입력을 g에 넘기면 왜 이 논리를 바로 쓸 수 없나요?
Under P, f returns a value satisfying Q; g guarantees R for Q inputs. The same returned value is passed to g and both terminate normally. State the conclusion and explain an old unrelated input.
풀이와 확인할 이유Solution and explanation
P에서 g(f(입력))은 R을 만족합니다. 첫 단계가 준 Q가 둘째의 입력 전제를 충족하기 때문입니다. 오래된 다른 값에는 Q가 성립한다고 확인되지 않아 합성 전제를 잃습니다.
The composition satisfies R under P because f supplies g’s precondition. Passing an unrelated old value loses the established Q premise and does not justify the same conclusion.
59. 입력을 바꾸는 함수A function mutating its input
평균 함수가 [1,결측,3]의 결측 행을 원목록에서 직접 삭제한 뒤 2를 반환했습니다. 평균 숫자는 맞지만 “입력을 보존한다”는 계약도 맞나요? 어떤 전후 비교를 남길 수 있나요?
A mean function deletes the missing row in place from [1,missing,3] and returns two. Does it satisfy an input-preservation contract, and what comparison exposes the failure?
풀이와 확인할 이유Solution and explanation
평균은 맞아도 입력 보존 계약은 실패합니다. 전 원목록의 세 위치·값과 후 목록 [1,3]을 비교해 원행 수 3→2와 결측 위치 소실을 남길 수 있습니다. 뒤 검사는 변경된 입력을 받으므로 그 영향도 분리합니다.
The number is correct but input preservation fails. Compare the three original positions with the resulting [1,3], recording count three→two and loss of the missing position. Later checks receive a changed input.
60. 다시 읽을 수 있는 실행 설명An inspectable execution statement
자료 계약 수업에서 실제 32개 Python/R 실행·의도적 실패 2개·그림 26개를 기록했습니다. 브라우저는 별도 JavaScript 계산입니다. 원자료·환경·기대 오류·표시·실행 범위를 포함하는 짧은 보고 문장을 작성하세요.
A data-contract lesson records 32 actual offline Python/R runs, two deliberate failures and 26 plots. Browser calculations separately use JavaScript. Write a short report covering source preservation, environment, expected errors, display and execution scope.
풀이와 확인할 이유Solution and explanation
예: “원행과 입력 해시를 보존한 오프라인 Python/R 32개를 실제 실행했다. 두 0 채움 테스트 묶음은 각각 네 사례 중 두 실패를 보존하며 예상 비영 종료했고, 성공 30개 중 환경 텍스트 네 개를 제외한 26개가 그림을 만들었다. 버전·R digits17·UTC와 실제 출력을 함께 남겼으며, 예상 숫자 오류 확인은 성공 테스트로 셌다. 화면의 새 입력은 JavaScript로 계산되며 새 Python/R 실행이나 HTTP 수집이 아니다.” 선택 사례의 결과 범위도 함께 적습니다.
For example: “Thirty-two offline Python/R programs actually ran with retained rows and input hashes. Both zero-filled suites preserved two failures among four cases and exited nonzero as expected. Thirty successes included four text-only environment programs and twenty-six plots. Versions, R digits 17, UTC and raw output were retained; expected numeric rejection counted as test success. New browser inputs use JavaScript rather than new Python/R or HTTP execution.” Keep the selected-case scope explicit.
자료별 확보일·원행 식별·단위·이용 조건은 출처 기록을 확인하세요. 학습 사본은 제공처의 현재 최신 자료와 다를 수 있습니다.Consult each source record for retrieval dates, row identifiers, units and terms. Teaching copies can differ from current provider releases.