Skip to content · ⁨본문 바로가기⁩

Stop at the first over fifty · ⁨50을 넘어가는 첫 번째 지점에서 멈추기⁩

English

Stop at the first over fifty

n starts at 1. Keep adding 1 to it. As soon as n * n is more than 50, leave the loop with break. Print n afterwards.

break leaves the loop at once. ⚠️ It only works inside the loop, so the if that holds it must be indented under the while too — and the break indented once more, under the if. print(n) stays at the left, outside the loop, so it runs after the break.

한국어

50을 넘어선 첫 번째 지점에서의 중단

n는 1에서 시작합니다. 1를 계속 더합니다. n * n이 50보다 커지는 즉시 break과 함께 루프에서 빠져나갑니다. 이후에 n을 출력합니다.

break는 즉시 루프를 나갑니다. ⚠️ 이는 루프 안에서만 작동하므로, 이를 저장하는 if도 while 아래에 들여쓰기되어야 하며, break은 한 단계 더 들여쓰기되어 if 아래에 위치해야 합니다. print(n)은 왼쪽 여백에 있어 루프 바깥에 있으므로 break 문장 다음에 실행됩니다.

Log in or create account · ⁨로그인 또는 계정 만들기⁩

IGCSE, A-Level & AP