Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 1ae2e93

Browse files
Data_type_and_Control_statement
1 parent 918c5ac commit 1ae2e93

23 files changed

+11781
-1326
lines changed
Lines changed: 300 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,300 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"id": "5f1c6f18",
6+
"metadata": {},
7+
"source": [
8+
"# Python Data type (int, float)\n",
9+
"# 파이썬 자료형 (정수, 실수)\n",
10+
"## Why 숫자형부터 시작?\n",
11+
"- 컴퓨터가 이해할 수 있는 단 하나의 언어: 기계어(machine language) with 0, 1\n",
12+
"\n",
13+
"## > 숫자형\n",
14+
"- 종류\n",
15+
" - 정수: 0, 양의 정수, 음의 정수\n",
16+
" - 실수: 소수점을 포함하는 숫자\n",
17+
" - 8진수 (0o or 0O로 시작): e.g. 0o34, 0o25\n",
18+
" - 16진수 (0x로 시작): e.g. 0x2A, 0xFF\n",
19+
" - 2진수 (0b로 시작): e.g. 0b10, 0b11\n",
20+
"- 8bit == 1byte"
21+
]
22+
},
23+
{
24+
"cell_type": "markdown",
25+
"id": "0efe7645",
26+
"metadata": {},
27+
"source": [
28+
"## 1) 정수형 (int)"
29+
]
30+
},
31+
{
32+
"cell_type": "code",
33+
"execution_count": 1,
34+
"id": "b75439af",
35+
"metadata": {},
36+
"outputs": [],
37+
"source": [
38+
"#양수, 음수, 0\n",
39+
"a = 10\n",
40+
"b = -20\n",
41+
"c = 0"
42+
]
43+
},
44+
{
45+
"cell_type": "code",
46+
"execution_count": 2,
47+
"id": "8f5defd8",
48+
"metadata": {},
49+
"outputs": [
50+
{
51+
"name": "stdout",
52+
"output_type": "stream",
53+
"text": [
54+
"10\n"
55+
]
56+
}
57+
],
58+
"source": [
59+
"# 출력 함수 > print(변수명)\n",
60+
"print(a)"
61+
]
62+
},
63+
{
64+
"cell_type": "code",
65+
"execution_count": 3,
66+
"id": "0a89e390",
67+
"metadata": {},
68+
"outputs": [
69+
{
70+
"name": "stdout",
71+
"output_type": "stream",
72+
"text": [
73+
"a\n"
74+
]
75+
}
76+
],
77+
"source": [
78+
"# print(string) > string \" \"안의 내용 출력\n",
79+
"print(\"a\")"
80+
]
81+
},
82+
{
83+
"cell_type": "code",
84+
"execution_count": 4,
85+
"id": "45799edc",
86+
"metadata": {},
87+
"outputs": [
88+
{
89+
"name": "stdout",
90+
"output_type": "stream",
91+
"text": [
92+
"Hello world\n"
93+
]
94+
}
95+
],
96+
"source": [
97+
"print(\"Hello world\")"
98+
]
99+
},
100+
{
101+
"cell_type": "code",
102+
"execution_count": 5,
103+
"id": "5f8abf86",
104+
"metadata": {},
105+
"outputs": [
106+
{
107+
"data": {
108+
"text/plain": [
109+
"int"
110+
]
111+
},
112+
"execution_count": 5,
113+
"metadata": {},
114+
"output_type": "execute_result"
115+
}
116+
],
117+
"source": [
118+
"# data type을 확인하는 함수 > type()\n",
119+
"type(a)"
120+
]
121+
},
122+
{
123+
"cell_type": "code",
124+
"execution_count": 6,
125+
"id": "0a8e7079",
126+
"metadata": {},
127+
"outputs": [
128+
{
129+
"data": {
130+
"text/plain": [
131+
"int"
132+
]
133+
},
134+
"execution_count": 6,
135+
"metadata": {},
136+
"output_type": "execute_result"
137+
}
138+
],
139+
"source": [
140+
"type(b)"
141+
]
142+
},
143+
{
144+
"cell_type": "code",
145+
"execution_count": 7,
146+
"id": "e3a2e75a",
147+
"metadata": {},
148+
"outputs": [
149+
{
150+
"data": {
151+
"text/plain": [
152+
"int"
153+
]
154+
},
155+
"execution_count": 7,
156+
"metadata": {},
157+
"output_type": "execute_result"
158+
}
159+
],
160+
"source": [
161+
"type(c)"
162+
]
163+
},
164+
{
165+
"cell_type": "markdown",
166+
"id": "42dfa06a",
167+
"metadata": {},
168+
"source": [
169+
"## 2) 실수형 (float)"
170+
]
171+
},
172+
{
173+
"cell_type": "code",
174+
"execution_count": 8,
175+
"id": "683a7278",
176+
"metadata": {},
177+
"outputs": [],
178+
"source": [
179+
"# 실수 data type == float\n",
180+
"a = 1.3\n",
181+
"b = -2.4\n",
182+
"c = 0.0"
183+
]
184+
},
185+
{
186+
"cell_type": "code",
187+
"execution_count": 9,
188+
"id": "12f5df76",
189+
"metadata": {},
190+
"outputs": [
191+
{
192+
"data": {
193+
"text/plain": [
194+
"float"
195+
]
196+
},
197+
"execution_count": 9,
198+
"metadata": {},
199+
"output_type": "execute_result"
200+
}
201+
],
202+
"source": [
203+
"# 실수 타입 확인\n",
204+
"type(a)"
205+
]
206+
},
207+
{
208+
"cell_type": "code",
209+
"execution_count": 10,
210+
"id": "0ed54cb0",
211+
"metadata": {},
212+
"outputs": [
213+
{
214+
"data": {
215+
"text/plain": [
216+
"float"
217+
]
218+
},
219+
"execution_count": 10,
220+
"metadata": {},
221+
"output_type": "execute_result"
222+
}
223+
],
224+
"source": [
225+
"type(b)"
226+
]
227+
},
228+
{
229+
"cell_type": "code",
230+
"execution_count": 11,
231+
"id": "eb030fb3",
232+
"metadata": {},
233+
"outputs": [
234+
{
235+
"data": {
236+
"text/plain": [
237+
"float"
238+
]
239+
},
240+
"execution_count": 11,
241+
"metadata": {},
242+
"output_type": "execute_result"
243+
}
244+
],
245+
"source": [
246+
"type(c)"
247+
]
248+
},
249+
{
250+
"cell_type": "code",
251+
"execution_count": 12,
252+
"id": "a9a3c198",
253+
"metadata": {},
254+
"outputs": [
255+
{
256+
"name": "stdout",
257+
"output_type": "stream",
258+
"text": [
259+
"<class 'int'> <class 'float'>\n"
260+
]
261+
}
262+
],
263+
"source": [
264+
"# 0 vs 0.0\n",
265+
"print(type(0), type(0.0))"
266+
]
267+
},
268+
{
269+
"cell_type": "code",
270+
"execution_count": 13,
271+
"id": "298733c3",
272+
"metadata": {},
273+
"outputs": [],
274+
"source": [
275+
"# 정수와 실수가 다른 숫자로 인식되는 이유: 2의 보수(정수) vs floating point(실수)"
276+
]
277+
}
278+
],
279+
"metadata": {
280+
"kernelspec": {
281+
"display_name": "Python 3 (ipykernel)",
282+
"language": "python",
283+
"name": "python3"
284+
},
285+
"language_info": {
286+
"codemirror_mode": {
287+
"name": "ipython",
288+
"version": 3
289+
},
290+
"file_extension": ".py",
291+
"mimetype": "text/x-python",
292+
"name": "python",
293+
"nbconvert_exporter": "python",
294+
"pygments_lexer": "ipython3",
295+
"version": "3.9.12"
296+
}
297+
},
298+
"nbformat": 4,
299+
"nbformat_minor": 5
300+
}
File renamed without changes.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"cells": [],
3+
"metadata": {},
4+
"nbformat": 4,
5+
"nbformat_minor": 5
6+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /