Skip to content

Commit 1cd7a8f

Browse files
committed
Update values.ipynb
1 parent dfff16a commit 1cd7a8f

File tree

1 file changed

+222
-20
lines changed

1 file changed

+222
-20
lines changed

values.ipynb

Lines changed: 222 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -649,22 +649,176 @@
649649
"id": "4f26c2eb",
650650
"metadata": {},
651651
"source": [
652-
"**문자열 비교 연산**"
652+
"**사전식 문자열 비교 연산**"
653653
]
654654
},
655655
{
656656
"cell_type": "markdown",
657657
"id": "39f305ba",
658658
"metadata": {},
659659
"source": [
660-
"두 값의 비교 연산은 정수, 부동소수점이 아닌 다른 종류의 값들에 대해서도 가능하다.\n",
661-
"예를 들어 두 문자열의 크기비교는 사전식 알파벳 순서를 사용한다."
660+
"두 값의 비교 연산은 정수, 부동소수점 뿐만 아니라 문자열 등 일부 다른 종류의 값들에 대해서도 가능하다.\n",
661+
"대표적으로 문자열의 크기 비교가 종종 활용되며, 두 문자열 중에 누가 더 큰지를 판단하는 기준으로 알파벳 순서를 활용한다.\n",
662+
"예를 들어, `ㄱ`은 `ㄴ`보다, `가`는 `나`보다, `a`는 `b`보다 작다."
662663
]
663664
},
664665
{
665666
"cell_type": "code",
666-
"execution_count": 2,
667-
"id": "11597968",
667+
"execution_count": 9,
668+
"metadata": {},
669+
"outputs": [
670+
{
671+
"data": {
672+
"text/plain": [
673+
"True"
674+
]
675+
},
676+
"execution_count": 9,
677+
"metadata": {},
678+
"output_type": "execute_result"
679+
}
680+
],
681+
"source": [
682+
"'ㄱ' < 'ㄴ'"
683+
]
684+
},
685+
{
686+
"cell_type": "code",
687+
"execution_count": 10,
688+
"metadata": {},
689+
"outputs": [
690+
{
691+
"data": {
692+
"text/plain": [
693+
"True"
694+
]
695+
},
696+
"execution_count": 10,
697+
"metadata": {},
698+
"output_type": "execute_result"
699+
}
700+
],
701+
"source": [
702+
"'가' < '나'"
703+
]
704+
},
705+
{
706+
"cell_type": "code",
707+
"execution_count": 8,
708+
"metadata": {},
709+
"outputs": [
710+
{
711+
"data": {
712+
"text/plain": [
713+
"True"
714+
]
715+
},
716+
"execution_count": 8,
717+
"metadata": {},
718+
"output_type": "execute_result"
719+
}
720+
],
721+
"source": [
722+
"'a' < 'b'"
723+
]
724+
},
725+
{
726+
"cell_type": "markdown",
727+
"metadata": {},
728+
"source": [
729+
"그리고 `가나다`는 `나다`보다, `도장`은 `서명`보다, `apple`은 `banana`보다, `baseball`은 `basic`보다 작다."
730+
]
731+
},
732+
{
733+
"cell_type": "code",
734+
"execution_count": 23,
735+
"metadata": {},
736+
"outputs": [
737+
{
738+
"data": {
739+
"text/plain": [
740+
"True"
741+
]
742+
},
743+
"execution_count": 23,
744+
"metadata": {},
745+
"output_type": "execute_result"
746+
}
747+
],
748+
"source": [
749+
"'가나다' < '나다'"
750+
]
751+
},
752+
{
753+
"cell_type": "code",
754+
"execution_count": 14,
755+
"metadata": {},
756+
"outputs": [
757+
{
758+
"data": {
759+
"text/plain": [
760+
"True"
761+
]
762+
},
763+
"execution_count": 14,
764+
"metadata": {},
765+
"output_type": "execute_result"
766+
}
767+
],
768+
"source": [
769+
"'도장' < '서명'"
770+
]
771+
},
772+
{
773+
"cell_type": "code",
774+
"execution_count": 11,
775+
"metadata": {},
776+
"outputs": [
777+
{
778+
"data": {
779+
"text/plain": [
780+
"True"
781+
]
782+
},
783+
"execution_count": 11,
784+
"metadata": {},
785+
"output_type": "execute_result"
786+
}
787+
],
788+
"source": [
789+
"'apple' < 'banana'"
790+
]
791+
},
792+
{
793+
"cell_type": "code",
794+
"execution_count": 24,
795+
"metadata": {},
796+
"outputs": [
797+
{
798+
"data": {
799+
"text/plain": [
800+
"True"
801+
]
802+
},
803+
"execution_count": 24,
804+
"metadata": {},
805+
"output_type": "execute_result"
806+
}
807+
],
808+
"source": [
809+
"'baseball' < 'basic'"
810+
]
811+
},
812+
{
813+
"cell_type": "markdown",
814+
"metadata": {},
815+
"source": [
816+
"반면에 `도장`은 `고무도장`보다, `nano banana`는 `banana`보다 작지 않다."
817+
]
818+
},
819+
{
820+
"cell_type": "code",
821+
"execution_count": 15,
668822
"metadata": {},
669823
"outputs": [
670824
{
@@ -673,19 +827,18 @@
673827
"False"
674828
]
675829
},
676-
"execution_count": 2,
830+
"execution_count": 15,
677831
"metadata": {},
678832
"output_type": "execute_result"
679833
}
680834
],
681835
"source": [
682-
"'apple' < 'Hello, World!'"
836+
"'도장' < '고무도장'"
683837
]
684838
},
685839
{
686840
"cell_type": "code",
687-
"execution_count": 3,
688-
"id": "38ddfd3a",
841+
"execution_count": 16,
689842
"metadata": {},
690843
"outputs": [
691844
{
@@ -694,25 +847,26 @@
694847
"False"
695848
]
696849
},
697-
"execution_count": 3,
850+
"execution_count": 16,
698851
"metadata": {},
699852
"output_type": "execute_result"
700853
}
701854
],
702855
"source": [
703-
"'Hello, World!' < ' hello'"
856+
"'nano banana' < 'banana'"
704857
]
705858
},
706859
{
707860
"cell_type": "markdown",
708861
"metadata": {},
709862
"source": [
710-
"특히 대문자가 소문자보다 작음에 주의한다."
863+
"그리고 `apple`은 `Apple`보다 크다."
711864
]
712865
},
713866
{
714867
"cell_type": "code",
715-
"execution_count": null,
868+
"execution_count": 25,
869+
"id": "11597968",
716870
"metadata": {},
717871
"outputs": [
718872
{
@@ -721,25 +875,26 @@
721875
"True"
722876
]
723877
},
878+
"execution_count": 25,
724879
"metadata": {},
725-
"output_type": "display_data"
880+
"output_type": "execute_result"
726881
}
727882
],
728883
"source": [
729-
"'A' <= 'a'"
884+
"'apple' > 'Apple'"
730885
]
731886
},
732887
{
733888
"cell_type": "markdown",
734889
"metadata": {},
735890
"source": [
736-
"문자열은 다른 문자열보다 항상 작다."
891+
"사실 영어 알파벳 소문자로 시작하는 문자열은 무조건 대문자 알파벳으로 시작하는 임의의 문자열보다 크다."
737892
]
738893
},
739894
{
740895
"cell_type": "code",
741-
"execution_count": 4,
742-
"id": "cc7a4354",
896+
"execution_count": 26,
897+
"id": "38ddfd3a",
743898
"metadata": {},
744899
"outputs": [
745900
{
@@ -748,13 +903,60 @@
748903
"True"
749904
]
750905
},
751-
"execution_count": 4,
906+
"execution_count": 26,
907+
"metadata": {},
908+
"output_type": "execute_result"
909+
}
910+
],
911+
"source": [
912+
"'a' > 'Hello'"
913+
]
914+
},
915+
{
916+
"cell_type": "code",
917+
"execution_count": 28,
918+
"metadata": {},
919+
"outputs": [
920+
{
921+
"data": {
922+
"text/plain": [
923+
"True"
924+
]
925+
},
926+
"execution_count": 28,
752927
"metadata": {},
753928
"output_type": "execute_result"
754929
}
755930
],
756931
"source": [
757-
"'' < 'a'"
932+
"'hello' > 'Hi'"
933+
]
934+
},
935+
{
936+
"cell_type": "markdown",
937+
"metadata": {},
938+
"source": [
939+
"사전식 문자열 크기 비교의 판단 기준을 정리하면 다음과 같다.\n",
940+
"\n",
941+
"1. 두 문자열을 첫 번째 문자부터 차례대로 비교\n",
942+
"2. 다른 문자를 발견하면 즉시 두 문자열의 크기 비교 판단\n",
943+
" - 같은 위치에서 다른 문자가 나오면, 그 문자들의 크기에 따라 전체 문자열의 크기 비교 판단\n",
944+
" - 각 문자의 크기는 유니코드 포인트 값으로 크기 비교.\n",
945+
" - 예: 'a' < 'b', 'A' < 'a', '고무도장' < '고무장갑'\n",
946+
"3. 한 문자열이 다른 문자열의 앞부분과 일치하면 짧은 문자열이 더 작다고 판단\n",
947+
" - 예: '도장' < '도장직인', 'apple' < 'apple파이'"
948+
]
949+
},
950+
{
951+
"cell_type": "markdown",
952+
"metadata": {},
953+
"source": [
954+
":::{tip} 유니코드 포인트\n",
955+
"\n",
956+
"유니코드 포인트<font size='2'>Unicode code point</font>는 유니코드에서 각 문자를 식별하기 위해 부여한 정수 번호이다.\n",
957+
"예를 들어, 대문자 ‘A’는 U+0041(10진수 65), 소문자 ‘a’는 U+0061(10진수 97)로 표현되며,\n",
958+
"이런한 이유로 대문자 알파벳이 소문자 알파벳보다 작다고 판단한다.\n",
959+
":::"
758960
]
759961
},
760962
{

0 commit comments

Comments
 (0)