이 페이지는 최신 브라우저(SharedArrayBuffer 지원)가 필요합니다. Chrome, Edge, Firefox 또는 Safari를 최신 버전으로 업데이트해 주세요.
English
Why validate input
- Validation checks that input is sensible before the program uses it.
- "Garbage in, garbage out" — bad data leads to wrong answers.
- The program decides to accept or reject the value.

탐색하기
The validation steps
Read the input, 검증 it, then accept or reject — bad data never gets used.
English
Range check
- A range check makes sure a number is between a low and a high limit.
- Example: a month must be from 1 to 12.
English
month = 13
if 1 <= month <= 12:
print("Accepted")
else:
print("Rejected")
English
Length check
- A length check makes sure text is not too short or too long.
len(text)gives the number of characters.
English
password = "abc"
if len(password) >= 8:
print("Accepted")
else:
print("Too short")
English
Presence check
- A presence check makes sure something was actually entered.
- An empty string
""means the user typed nothing.
English
Verification: checking the copy
- Verification checks that data was copied or typed correctly.
- A double-entry check asks for the value twice and compares them.
- A visual check means a human reads it back on screen.
English
In the exam: types of check
- Know these validation checks: range, length, type, presence, format, check digit.
IF Age >= 0 AND Age <= 120
THEN
OUTPUT "Valid"
ELSE
OUTPUT "Invalid"
ENDIF
English
Common mistakes
- Validation checks data is sensible (range, length, type); verification checks it was entered correctly.
- A range check needs both a lower and an upper limit.
English
Now you try
- Each function returns
Trueto accept orFalseto reject. - Press Check answer to test your code.
난이도 2/5 · 140코인 + 오늘 첫 완료 시 작은 보너스 추가
Write valid_age(a) that returns True when a is a sensible age (0 to 120 inclusive), otherwise False. This is a range check.
출력을 보려면 '실행'을 클릭하세요.
난이도 2/5 · 140코인 + 오늘 첫 완료 시 작은 보너스 추가
Write valid_password(p) that returns True when the password is at least 8 characters long. This is a length check.
출력을 보려면 '실행'을 클릭하세요.
난이도 2/5 · 140코인 + 오늘 첫 완료 시 작은 보너스 추가
Write is_present(s) that returns True when something was entered, and False for an empty string "". This is a presence check.
출력을 보려면 '실행'을 클릭하세요.