Created
February 17, 2023 02:28
-
-
Save hvnsweeting/1ca5e68c6d2d30dfb0fe65b96988fe1d to your computer and use it in GitHub Desktop.
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", | |
"id": "56fbc1e1", | |
"metadata": {}, | |
"source": [ | |
"# Welcome to Pymi.vn" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "b71bc300", | |
"metadata": {}, | |
"source": [ | |
"## nhớ chuẩn bị theo https://gitlab.com/pyfml/prepare nhé hihi" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "53bd00e4", | |
"metadata": {}, | |
"source": [ | |
"## chuẩn bị\n", | |
"- tải Python \n", | |
"- tải tài liệu https://docs.python.org/3/\n", | |
"- vào slack https://pymi-invite.fly.dev/" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "e3feeb2f", | |
"metadata": {}, | |
"source": [ | |
"## Euler" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "17df6d2c", | |
"metadata": {}, | |
"source": [ | |
"https://projecteuler.net/" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "005ef80a", | |
"metadata": {}, | |
"source": [ | |
"https://projecteuler.net/problem=1\n", | |
"\n", | |
"\n", | |
"\n", | |
"If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.\n", | |
"\n", | |
"Find the sum of all the multiples of 3 or 5 below 1000.\n" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "e20b4e73", | |
"metadata": {}, | |
"source": [ | |
"FOR : IF" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"id": "00420e99", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"233168" | |
] | |
}, | |
"execution_count": 2, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"sum(i for i in range(1000) \n", | |
" if i % 3 == 0 or i % 5 == 0)" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "24b6155f", | |
"metadata": {}, | |
"source": [ | |
"## ra choi -> 20:32" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "6eddd3b1", | |
"metadata": {}, | |
"source": [ | |
"## bật tắt python" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "e3f128ab", | |
"metadata": {}, | |
"source": [ | |
"```py\n", | |
"$ python3 [0]\n", | |
"Python 3.8.10 (default, Nov 14 2022, 12:59:47) \n", | |
"[GCC 9.4.0] on linux\n", | |
"Type \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n", | |
">>> exit()\n", | |
"```" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "7130ee80", | |
"metadata": {}, | |
"source": [ | |
"### >>> - prompt" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "ce768fd8", | |
"metadata": {}, | |
"source": [ | |
">>> 1 + 1\n", | |
"2\n" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "6879514f", | |
"metadata": {}, | |
"source": [ | |
"## Toán" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "2e14f66c", | |
"metadata": {}, | |
"source": [ | |
"## Cộng - add" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 4, | |
"id": "9fd4ff29", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"3" | |
] | |
}, | |
"execution_count": 4, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"1 + 2" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 5, | |
"id": "c7288239", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"7" | |
] | |
}, | |
"execution_count": 5, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"3 + 4" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 6, | |
"id": "bb22cf93", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"589347589234759823475983279193226809629221" | |
] | |
}, | |
"execution_count": 6, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"589347589234759823475983275982734985724398 + 3210491823904823" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 7, | |
"id": "86ea3a46", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"ename": "SyntaxError", | |
"evalue": "leading zeros in decimal integer literals are not permitted; use an 0o prefix for octal integers (969423683.py, line 1)", | |
"output_type": "error", | |
"traceback": [ | |
"\u001b[0;36m File \u001b[0;32m\"/tmp/ipykernel_36581/969423683.py\"\u001b[0;36m, line \u001b[0;32m1\u001b[0m\n\u001b[0;31m 01 + 02\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m leading zeros in decimal integer literals are not permitted; use an 0o prefix for octal integers\n" | |
] | |
} | |
], | |
"source": [ | |
"01 + 02" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "0b381b2c", | |
"metadata": {}, | |
"source": [ | |
"### KẾT LUẬN: CỘNG THOẢI MÁI " | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "f965fb05", | |
"metadata": {}, | |
"source": [ | |
"## Trừ - subtract" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 8, | |
"id": "a2c132ee", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"2" | |
] | |
}, | |
"execution_count": 8, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"4 - 2" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 9, | |
"id": "1bae4383", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"-1" | |
] | |
}, | |
"execution_count": 9, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"1 - 2" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 10, | |
"id": "a20af596", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"-23745923485923473425923745892374598723489572349875982347589273489572348957239847589237459872389475298319613684252094" | |
] | |
}, | |
"execution_count": 10, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"27984589237485 -23745923485923473425923745892374598723489572349875982347589273489572348957239847589237459872389475298347598273489579" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "4a981a48", | |
"metadata": {}, | |
"source": [ | |
"### nhân : multiply" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 11, | |
"id": "578da5d0", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"6" | |
] | |
}, | |
"execution_count": 11, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"3 * 2" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 13, | |
"id": "b666605e", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"42" | |
] | |
}, | |
"execution_count": 13, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"21 * 2" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 14, | |
"id": "b3c6fd1f", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"7212122479522879905222737763176226608338129524589135551497324707270966498374536878301803792400845226" | |
] | |
}, | |
"execution_count": 14, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"12378461872648723647823648721374613278461278346281 * 582634785623784562378456278345627834563728456872346" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "e17afb38", | |
"metadata": {}, | |
"source": [ | |
"## nhân thoải mái " | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "e690add3", | |
"metadata": {}, | |
"source": [ | |
"### phép lũy thừa - power\n" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 15, | |
"id": "beec1766", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"256" | |
] | |
}, | |
"execution_count": 15, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"2 ** 8" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "c1ba3e15", | |
"metadata": {}, | |
"source": [ | |
"### 2 to the power of 8" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 16, | |
"id": "91da44c1", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"18446744073709551616" | |
] | |
}, | |
"execution_count": 16, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"2 ** (8 * 8)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "acb0c244", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
">>> 2**14424311231231231\n", | |
"^C^CError in sys.excepthook:\n", | |
"Traceback (most recent call last):\n", | |
" File \"/usr/lib/python3/dist-packages/apport_python_hook.py\", line 34, in apport_excepthook\n", | |
" def apport_excepthook(exc_type, exc_obj, exc_tb):\n", | |
"KeyboardInterrupt\n", | |
"\n", | |
"\n", | |
"Ctrl C\n" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "417f1a0f", | |
"metadata": {}, | |
"source": [ | |
"## chia - devide" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 17, | |
"id": "39204c5e", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"2.0" | |
] | |
}, | |
"execution_count": 17, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"4/2 " | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "8f04fa94", | |
"metadata": {}, | |
"source": [ | |
"## / - slash" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "61840d5b", | |
"metadata": {}, | |
"source": [ | |
"- Tiến: gạch chéo - gạch phải \n", | |
"- Cảnh: xuộc chéo - huyền - xoạc phải -....\n", | |
"- Đạt: gạch chéo\n", | |
"- Đức: gạch chéo\n", | |
"- Hưng: xược \n", | |
"- Hiệp: gạch xược" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "23934541", | |
"metadata": {}, | |
"source": [ | |
"## \\ - backslash " | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 19, | |
"id": "1ea4592b", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"2.0" | |
] | |
}, | |
"execution_count": 19, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"4 / 2" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 20, | |
"id": "5a0f11a8", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"int" | |
] | |
}, | |
"execution_count": 20, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"type(2)" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "760b7c1b", | |
"metadata": {}, | |
"source": [ | |
"## integer" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 21, | |
"id": "bbe8b77f", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"float" | |
] | |
}, | |
"execution_count": 21, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"type(2.0)" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "77a1f519", | |
"metadata": {}, | |
"source": [ | |
"## float uk /fləʊt/ us /floʊt/" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "96dae652", | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "eb9cbf74", | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "1bb0161b", | |
"metadata": {}, | |
"source": [ | |
"### cache - cake " | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "41149d40", | |
"metadata": {}, | |
"source": [ | |
"### cache /kæʃ/ - cash" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "76178a84", | |
"metadata": {}, | |
"source": [ | |
"## sort - /sɔːrt/" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "586bb6ea", | |
"metadata": {}, | |
"source": [ | |
"## resort - /rɪˈzɔːrt/" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "324093ae", | |
"metadata": {}, | |
"source": [ | |
"## suit /suːt/" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "1351fe46", | |
"metadata": {}, | |
"source": [ | |
"## test suite - /swiːt/ - sweet" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "35ed5927", | |
"metadata": {}, | |
"source": [ | |
"## float - số thực" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 22, | |
"id": "bab951f7", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"2.0" | |
] | |
}, | |
"execution_count": 22, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"4 / 2" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "6b85cdb9", | |
"metadata": {}, | |
"source": [ | |
"## số thực Z\n", | |
"- số hữu tỷ: có tỷ lệ /tỷ số : phân số 10/3\n", | |
"- số vô tỷ: không tỷ lệ / tỷ số: không viết được thành phân soo" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "1aee99c5", | |
"metadata": {}, | |
"source": [ | |
"căn 2, pi" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 23, | |
"id": "8c9120af", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"import math" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 27, | |
"id": "146c7c96", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"3.3333333333333335" | |
] | |
}, | |
"execution_count": 27, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"10/3" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 24, | |
"id": "fa3dabac", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"3.141592653589793" | |
] | |
}, | |
"execution_count": 24, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"math.pi" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 25, | |
"id": "46eb4aea", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"1.4142135623730951" | |
] | |
}, | |
"execution_count": 25, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"math.sqrt(2)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 26, | |
"id": "845bd9b8", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"1.4142135623730951" | |
] | |
}, | |
"execution_count": 26, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"2 ** (1/2)" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "4fd60876", | |
"metadata": {}, | |
"source": [ | |
"## float là kiểu gần đúng" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 29, | |
"id": "c5aea53d", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"0.2" | |
] | |
}, | |
"execution_count": 29, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"0.1 + 0.1 " | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 30, | |
"id": "3aecff3a", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"True" | |
] | |
}, | |
"execution_count": 30, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"0.1 + 0.1 == 0.2" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 31, | |
"id": "6781c2a7", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"False" | |
] | |
}, | |
"execution_count": 31, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"1 + 1 == 3" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 32, | |
"id": "9e6199e0", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"False" | |
] | |
}, | |
"execution_count": 32, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"0.1 + 0.2 == 0.3 " | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 34, | |
"id": "ad78da45", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"0.30000000000000004" | |
] | |
}, | |
"execution_count": 34, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"0.1 + 0.2" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 35, | |
"id": "0df99d75", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"0.30000000000000004" | |
] | |
}, | |
"execution_count": 35, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"0.1 + 0.1 + 0.1" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "0192500a", | |
"metadata": {}, | |
"source": [ | |
" https://pymi.vn/blog/why-not-float/" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "040089f1", | |
"metadata": {}, | |
"source": [ | |
"https://duckduckgo.com/?t=ffab&q=ieee+754&ia=web" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "2c5fabc4", | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 3 (ipykernel)", | |
"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.8.10" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 5 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment