Created
August 6, 2019 14:07
-
-
Save hvnsweeting/c2551dec0f4208ca08fe7f6b71f190c1 to your computer and use it in GitHub Desktop.
Học Python tại https://pymi.vn lớp HCM 01
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
{ | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"# Pymi HCM 1908\n", | |
"## Chuẩn bị https://gitlab.com/pyfml/prepare \n", | |
"## Lớp không có wifi, ổ điện hạn chế, pin yếu ngồi trên, hv tự chuẩn bị ổ điện các buổi sau\n", | |
"## Cài Python, bật python\n", | |
"## Tải tài liệu \n", | |
"Tải sẵn tài liệu ở định dạng HTML https://docs.python.org/3.6/download.html\n", | |
"giải nén ra và xem trên máy (vào file index.html). Mở sẳn mục \"Tutorial\" (tương đương với\n", | |
"xem online tại https://docs.python.org/3/tutorial/index.html). Nếu link die, thử\n", | |
"lại với link https://docs.python.org/3/download.html\n" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"## Vào kênh chat slack https://invite.pymi.vn/" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"https://projecteuler.net/" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"233168" | |
] | |
}, | |
"execution_count": 1, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"sum(i for i in range(1000) if i % 3 == 0 or i % 5 == 0)" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"## SaltStack & Ansible" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"https://www.familug.org/2015/06/saltstack-chao-muoi-em-la-ai.html" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"https://www.familug.org" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"## Lesson 1" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"## Bat & Tat" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"```python\n", | |
"$ python3\n", | |
"Python 3.6.5 (default, May 12 2018, 11:30:25) \n", | |
"[GCC 5.4.0 20160609] on linux\n", | |
"Type \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n", | |
">>> 1213 + 12312 \n", | |
"13525\n", | |
">>> exit()\n", | |
"\n", | |
"```" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"### `>>>` - Prompt" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"## Cong tru nhan chia " | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"## Integer" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"2" | |
] | |
}, | |
"execution_count": 2, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"1 + 1 " | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"9477" | |
] | |
}, | |
"execution_count": 3, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"567 + 8910 " | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"## add (+)" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"73214987239847923174198377321498723984792317419837732149872398479231741983773214987239847923174198377321498723984792317419837732149872398479231741983773214987239847923174198377321498723984792317419837732149872398479231741983773214987239847923174198377321498723984792317419837732149872398479231741983773214987239847923174198377321498723984792317419837732149872398479231741983773214987239847923174198377321498723984792317419837732149872398479231741983773214987239847923174198377321498723984792317419837732149872398479231741983773214987239847923174198377321498723984792317419837732149872398479231741983773214987239847923174198377321498723984792317419837732149872398479231741983773214987239847923174198377321498723984792317419837732149872398479231741983773214987239847923174198377321498723984792317419837732149872398479231741983773214987239847923174198377321498723984792317419837732149872398479231741983773214987239847923174198377321498723984792317419837732149872398479231741983773214987239847923174198377321498723984792317419837732149872398479231741983773214987239847923174198377321498723984792317419837732149872398479231741983773214987239847923174198377321498723984792317419837732149872398479231741983773214987239847923174198377321498723984792317419837732149872398479231741983773214987239847923174198377321498723984792317419837732149872398479231741983773214987239847923174198377321498723984792317419837" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"## Lớp kết luận: cộng thoải mái " | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"## subtract (-)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 4, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"-8" | |
] | |
}, | |
"execution_count": 4, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"2 - 10" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"## Trừ: thoải mái " | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"## Nhân - multiply (`*`) " | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 5, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"42" | |
] | |
}, | |
"execution_count": 5, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"7 * 6" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 6, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"310037127509886901272919511476697759087821637868913126822201422080709844587510597462693537925590228370851270524486778019599799064279477961976348017676104343190347527489407537230225843289885734401330685001736754501871986190764698088918001517053224846089600416055284690783061570939194031041767624363853291834645655506617042154948974988820683647164792456876651307581663262536941885580373309496180859463808349561586082603546523342814108584121558900710030479326100963485744676772667724134351481559928254228751565860661454538883119073071828617475308488721092742176022668637417872109274217602266863741787210927421760226686374178721092742176022668637417872109274217602266863741787210927421760226686374178721061738463271679947290580158126547826358081578000319614739540084478303194262341682429753314844858849272189090549818185939827231020993812430488739376953482307856987915888477118386251633273278290301654142427248084776499175559644622933284222516932095387500314175996738394663481053833502357122509611742335763558711457117975713656614376718720198499025307965239756629468520047925026904184138691719019331925728439261443658603387134876646010901814530484107718044809565926320062950194842501804167118707748961788052265174160540920290409185434993160921106569" | |
] | |
}, | |
"execution_count": 6, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"42346128736487216487732149872398479231741983773214987239847923174198377321498723984792317419837732149872398479231741983773214987239847923174198377321498723984792317419837732149872398479231741983773214987239847923174198377321498723984792317419837732149872398479231741983773214987239847923174198377321498723984792317419837732149872398479231741983773214987239847923174198377321498723984792317419837732149872398479231741983773214987239847923174198377321498723984792317419837732149872398479231741983773214987239847923174198377321498723984792317419837 * 7321498723984792317419837732149872398479231741983773214987239847923174198377321498723984792317419837732149872398479231741983773214987239847923174198377321498723984792317419837732149872398479231741983773214987239847923174198377321498723984792317419837732149872398479231741983773214987239847923174198377321498723984792317419837732149872398479231741983773214987239847923174198377321498723984792317419837732149872398479231741983773214987239847923174198377321498723984792317419837732149872398479231741983773214987239847923174198377321498723984792317419837732149872398479231741983773214987239847923174198377321498723984792317419837732149872398479231741983773214987239847923174198377321498723984792317419837" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"## Nhân vô tư " | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"## Phép mũ: (power)" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"## `**`" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 7, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"4294967296" | |
] | |
}, | |
"execution_count": 7, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"2 ** 32 " | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"## Bấm Ctrl C để dừng tính (Linux & OSX)" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"## Phép chia : divide (`/`)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 8, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"2.5" | |
] | |
}, | |
"execution_count": 8, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"5 / 2" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"## `/` - slash\n", | |
"- Như: xuyệt \n", | |
"- Hương: xẹc \n", | |
"- An: ???\n", | |
"- Bình: xuyệt \n", | |
"- Xẹc trái\n", | |
"- Sắc\n", | |
"\n" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"# `\\`- backslash\n", | |
"- Bình: xuyệt trái\n", | |
"- An: Huyền\n", | |
"- Xuyệt phải\n", | |
"- Như: không biết" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 10, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"2.5" | |
] | |
}, | |
"execution_count": 10, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"5 / 2" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"##" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 9, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"ename": "ZeroDivisionError", | |
"evalue": "division by zero", | |
"output_type": "error", | |
"traceback": [ | |
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", | |
"\u001b[0;31mZeroDivisionError\u001b[0m Traceback (most recent call last)", | |
"\u001b[0;32m<ipython-input-9-aaed92358df0>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0;36m50\u001b[0m \u001b[0;34m/\u001b[0m \u001b[0;36m0\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", | |
"\u001b[0;31mZeroDivisionError\u001b[0m: division by zero" | |
] | |
} | |
], | |
"source": [ | |
"50 / 0" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"## xảy ra exception: ZeroDivisionError" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 11, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"50.0" | |
] | |
}, | |
"execution_count": 11, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"50 / 1" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"## 50 " | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 12, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"<class 'int'>" | |
] | |
}, | |
"execution_count": 12, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"type(50)" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"## int - Integer /ˈɪntɪdʒə/ " | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 13, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"<class 'float'>" | |
] | |
}, | |
"execution_count": 13, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"type(50.0)" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"# float/fləʊt/ " | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"## suite \n", | |
"\n", | |
"## resort resort/rɪˈzɔːt/ " | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"## float - số thực " | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"## số thực: gồm số hữu tỷ và số vô tỷ \n", | |
"- hữu tỷ: có tỷ lệ - viết được ở dạng phân số\n", | |
"- vô tỷ: ko có tỷ lệ - không viết được ở dạng phana số: căn 2, pi , e" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 14, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"1.4142135623730951" | |
] | |
}, | |
"execution_count": 14, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"2 ** (1/2)" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"## float - là gần đúng " | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 17, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"True" | |
] | |
}, | |
"execution_count": 17, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"0.1 + 0.1 == 0.2 " | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 18, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"False" | |
] | |
}, | |
"execution_count": 18, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"0.1 + 0.1 + 0.1 == 0.3" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 19, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"0.30000000000000004" | |
] | |
}, | |
"execution_count": 19, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"0.1 + 0.1 + 0.1" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"## tránh so sánh kiểu float " | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"https://pymi.vn/blog/why-not-float/" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
}, | |
{ | |
"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.5" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment