Skip to content

Commit b47ccb7

Browse files
committed
up
1 parent ae5abbb commit b47ccb7

19 files changed

+3364
-11515
lines changed

functions.ipynb

Lines changed: 323 additions & 1983 deletions
Large diffs are not rendered by default.

practices/practice-dicts-sets.ipynb

Lines changed: 0 additions & 804 deletions
This file was deleted.

practices/practice-exception-handling.ipynb

Lines changed: 0 additions & 991 deletions
This file was deleted.

practices/practice-files.ipynb

Lines changed: 0 additions & 593 deletions
This file was deleted.

practices/practice-functions.ipynb

Lines changed: 1716 additions & 1236 deletions
Large diffs are not rendered by default.

practices/practice-iteration-for-sol.ipynb

Lines changed: 404 additions & 190 deletions
Large diffs are not rendered by default.

practices/practice-iteration-for.ipynb

Lines changed: 0 additions & 774 deletions
This file was deleted.

practices/practice-iteration-while-sol.ipynb

Lines changed: 83 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,88 @@
733733
"- 각각의 `i`에 대해 `i < j` 가 참이면 `continue` 명령문이 실행되어 `for` 반복문에서 `j`의 다음 경우로 넘어감..\n",
734734
"- 결론적으로 `i >= j`인 경우에만 `[i, j]` 출력."
735735
]
736+
},
737+
{
738+
"cell_type": "markdown",
739+
"id": "9e9c1ca3",
740+
"metadata": {},
741+
"source": [
742+
"**문제 3**"
743+
]
744+
},
745+
{
746+
"cell_type": "markdown",
747+
"id": "32e25327",
748+
"metadata": {},
749+
"source": [
750+
"아래 코드의 실행 결과를 설명하라.\n",
751+
"반복문 실행횟수는 얼마인가?"
752+
]
753+
},
754+
{
755+
"cell_type": "code",
756+
"execution_count": null,
757+
"id": "ac26b233",
758+
"metadata": {},
759+
"outputs": [
760+
{
761+
"name": "stdout",
762+
"output_type": "stream",
763+
"text": [
764+
"1\n",
765+
"=\n",
766+
"*\n"
767+
]
768+
},
769+
{
770+
"data": {
771+
"text/plain": [
772+
"100"
773+
]
774+
},
775+
"metadata": {},
776+
"output_type": "display_data"
777+
}
778+
],
779+
"source": [
780+
"def counter_func(num, limit) :\n",
781+
" i = 1\n",
782+
" while True :\n",
783+
" print(i)\n",
784+
" if i == limit :\n",
785+
" return i\n",
786+
" else:\n",
787+
" print(\"=\" * i)\n",
788+
" print(\"*\" * i)\n",
789+
" i += 1\n",
790+
" return num\n",
791+
"\n",
792+
"counter_func(100, 5)"
793+
]
794+
},
795+
{
796+
"cell_type": "markdown",
797+
"id": "215cefda",
798+
"metadata": {},
799+
"source": [
800+
"**답**"
801+
]
802+
},
803+
{
804+
"cell_type": "markdown",
805+
"id": "e3bc4603",
806+
"metadata": {},
807+
"source": [
808+
"`counter_func(100, 5)`이 호출되면 함수의 본문이 차례대로 실행된다.\n",
809+
"`i = 1` 에서 시작하고 `while True` 반복문이 실행된다.\n",
810+
"논리식 `True`가 참이라 `while` 반복문이 무한 반복되어야 하는 것처럼 보인다.\n",
811+
"`print(i)`에 의해 1이 출력되고\n",
812+
"`if ... else ...` 조건문에서 `i == limit`가 거짓이기에 `else`의 본문이 실행되어\n",
813+
"`\"=\"`와 `\"*\"` 가 출력된다.\n",
814+
"\n",
815+
"그런데 바로 이어서 `return num` 이 실행되어 100을 반환하고 반복문을 비롯해서\n",
816+
"함수의 실행이 완전히 종료된다."
817+
]
736818
}
737819
],
738820
"metadata": {
@@ -759,4 +841,4 @@
759841
},
760842
"nbformat": 4,
761843
"nbformat_minor": 5
762-
}
844+
}

0 commit comments

Comments
 (0)