-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9999ccc
commit 6f08fa7
Showing
1 changed file
with
231 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,231 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Python Review" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"### Data Type\n", | ||
"**Number & Boolean**" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 25, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"<class 'int'> 9\n", | ||
"1.5\n", | ||
"1\n", | ||
"--------------------\n", | ||
"<class 'bool'> False True True\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"x = 3\n", | ||
"y = 2\n", | ||
"print(type(x),x**2) #Square is **\n", | ||
"print(x/y)\n", | ||
"print(x//y)\n", | ||
"print('-'*20)\n", | ||
"t = True\n", | ||
"f = False\n", | ||
"print(type(t), t and f, t or f, not f)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"** String **" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"hello~world\n", | ||
"hello world and digit:11 and float 0.1235\n", | ||
"Hello HELLO hEllo\n", | ||
"'hello_world \n", | ||
"'\n", | ||
"'hello_world'\n", | ||
"['hello', 'world']\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"hello = 'hello'\n", | ||
"world = 'world'\n", | ||
"print(hello + '~' + world)\n", | ||
"print('%s %s and digit:%d and float %.4f'%(hello,world,11,0.123456))\n", | ||
"print(hello.capitalize(),hello.upper(),hello.replace('e','E'))\n", | ||
"\n", | ||
"s = 'hello_world \\n'\n", | ||
"print(\"'\"+s+\"'\")\n", | ||
"print(\"'\"+s.strip()+\"'\")\n", | ||
"print(s.strip().split('_'))" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"### Container\n", | ||
"** List **" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"[0, 1, 2, 3] [4, 3, 2, 1, 0]\n", | ||
"range(0, 5) [0, 1, 2, 3, 4]\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"xs = [0,1,2,3,4]\n", | ||
"r = range(5)\n", | ||
"print(xs[:-1],xs[::-1]) #[::-1] is reverse\n", | ||
"print(r, list(r))\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"0\n", | ||
"1\n", | ||
"2\n", | ||
"3\n", | ||
"4\n", | ||
"0\n", | ||
"1\n", | ||
"2\n", | ||
"3\n", | ||
"4\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"for i in r:\n", | ||
" print(i)\n", | ||
"for i in xs:\n", | ||
" print(i)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 4, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"0 0\n", | ||
"1 1\n", | ||
"2 2\n", | ||
"3 3\n", | ||
"4 4\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"for i,data in enumerate(r):\n", | ||
" print(i,data)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"list comprehension" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 5, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"[0, 1, 4, 9, 16]\n", | ||
"[0, 4, 16]\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"a = [x**2 for x in xs]\n", | ||
"b = [x**2 for x in xs if x%2==0]\n", | ||
"print(a)\n", | ||
"print(b)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"#### Dictionary, Tuple , Function , Class\n", | ||
"** Learn yourself **" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.6.4" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |