Last active
April 6, 2021 14:35
-
-
Save hvnsweeting/fd6110ea87322c7018105d576abb7731 to your computer and use it in GitHub Desktop.
Học Python tại Pymi.vn
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": "announced-roberts", | |
"metadata": {}, | |
"source": [ | |
"# Welcome to Pymi.vn\n", | |
"## Lesson 1\n", | |
"\n", | |
"https://pymi.vn/\n", | |
"\n", | |
"- Cài đặt Python 3.8 (hoặc mới hơn)\n", | |
"- Tải tài liệu về máy để xem offline\n", | |
"- Tham gia Slack: slack.pymi.vn (tìm slack trong email của bạn) - cài app di động slack" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "ruled-correction", | |
"metadata": {}, | |
"source": [ | |
"## THỨ 5 HỌC TẠI 30 TRUNG LIỆT" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "foster-laugh", | |
"metadata": {}, | |
"source": [ | |
"https://gitlab.com/pyfml/prepare" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "round-publication", | |
"metadata": {}, | |
"source": [ | |
"Học lập trình Python chất lượng số 1 Việt Nam 2021 - đào tạo học viên từ không biết gì thành lập trình viên chuyên nghiệp. Đã đào tạo hơn 1000 lập trình viên ..." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "racial-raleigh", | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "moderate-facility", | |
"metadata": {}, | |
"source": [ | |
"## PE" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "painted-cancer", | |
"metadata": {}, | |
"source": [ | |
"https://projecteuler.net/problem=1" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "civil-variation", | |
"metadata": {}, | |
"source": [ | |
"Multiples of 3 and 5\n", | |
"[Show HTML problem content] \n", | |
"Problem 1\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": "code", | |
"execution_count": 1, | |
"id": "manual-dispatch", | |
"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", | |
"id": "covered-rebound", | |
"metadata": {}, | |
"source": [ | |
"## ra chơi đến 20h40" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "lonely-finding", | |
"metadata": {}, | |
"source": [ | |
"# Vào lớp" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "american-drove", | |
"metadata": {}, | |
"source": [ | |
"```python\n", | |
"$ python3\n", | |
"Python 3.8.5 (default, Jan 27 2021, 15:41:15) \n", | |
"[GCC 9.3.0] on linux\n", | |
"Type \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n", | |
">>> exit()\n", | |
"```" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "impressive-python", | |
"metadata": {}, | |
"source": [ | |
"## `>>>` - prompt" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "concerned-excitement", | |
"metadata": {}, | |
"source": [ | |
"```python\n", | |
">>> 2 + 5\n", | |
"7\n", | |
"```" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "racial-hundred", | |
"metadata": {}, | |
"source": [ | |
"## Tính toán" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "western-invasion", | |
"metadata": {}, | |
"source": [ | |
"## Cộng (`+`) - add " | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"id": "realistic-diesel", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"6" | |
] | |
}, | |
"execution_count": 2, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"3 + 3" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"id": "consistent-hybrid", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"61" | |
] | |
}, | |
"execution_count": 3, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"4 + 5 + 52" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 4, | |
"id": "lucky-pledge", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"7" | |
] | |
}, | |
"execution_count": 4, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"2+2+3" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 5, | |
"id": "located-weapon", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"7485298375983275439285798237600583321730531724296795" | |
] | |
}, | |
"execution_count": 5, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"2345732495742398573298 + 7485298375983275439285798237598237589234789325723497" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 6, | |
"id": "utility-sleeve", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"24232" | |
] | |
}, | |
"execution_count": 6, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"-2 + 24234" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "fossil-porcelain", | |
"metadata": {}, | |
"source": [ | |
"## Lớp kết luận: cộng thoải mái" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "human-american", | |
"metadata": {}, | |
"source": [ | |
"## Trừ `-` : subtract" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 7, | |
"id": "golden-dealer", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"-5" | |
] | |
}, | |
"execution_count": 7, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"5 - 10" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 8, | |
"id": "sharp-profession", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"15" | |
] | |
}, | |
"execution_count": 8, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"5 - -10" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 9, | |
"id": "given-ceremony", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"-41234132431241324123431243412341324141324123413241324321421412341234124123413242314132431412341234312421421421" | |
] | |
}, | |
"execution_count": 9, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"0-41234132431241324123431243412341324141324123413241324321421412341234124123413242314132431412341234312421421421" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "talented-generic", | |
"metadata": {}, | |
"source": [ | |
"## Kết luận: trừ thoải mái" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "stone-scotland", | |
"metadata": {}, | |
"source": [ | |
"## Phép nhân - `*` : multiply" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 10, | |
"id": "steady-memorial", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"553847717473392544031230576480610410586619153714573713315698542788909819182599248922404" | |
] | |
}, | |
"execution_count": 10, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"132412346213749873298471894789317431298* 4182749821374891278439712983484721987483921732498" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 11, | |
"id": "intensive-freight", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999" | |
] | |
}, | |
"execution_count": 11, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 13, | |
"id": "vertical-connection", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999989999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001" | |
] | |
}, | |
"execution_count": 13, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 * 99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "democratic-accordance", | |
"metadata": {}, | |
"source": [ | |
"## lớp kết luận: nhân thoải mái" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "executive-chamber", | |
"metadata": {}, | |
"source": [ | |
"## phép chia: `/` - divise" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "drawn-netscape", | |
"metadata": {}, | |
"source": [ | |
"## `/` - đọc là gì? - slash" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "distant-lender", | |
"metadata": {}, | |
"source": [ | |
"\n", | |
"# `\\` - backslash" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 14, | |
"id": "encouraging-chase", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"2.0" | |
] | |
}, | |
"execution_count": 14, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"4 / 2" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 15, | |
"id": "clean-settle", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"2" | |
] | |
}, | |
"execution_count": 15, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"1 + 1" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 16, | |
"id": "auburn-floating", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"2.5" | |
] | |
}, | |
"execution_count": 16, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"5/2" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 17, | |
"id": "brazilian-virtue", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"0.3333333333333333" | |
] | |
}, | |
"execution_count": 17, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"1/3" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "determined-complaint", | |
"metadata": {}, | |
"source": [ | |
"## kiểu dữ liệu (data type)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 18, | |
"id": "adopted-simulation", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"int" | |
] | |
}, | |
"execution_count": 18, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"type(2)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 19, | |
"id": "textile-brother", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"float" | |
] | |
}, | |
"execution_count": 19, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"type(2.0)" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "equal-measurement", | |
"metadata": {}, | |
"source": [ | |
"## int - integer: số nguyên" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "precious-boring", | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "stunning-doubt", | |
"metadata": {}, | |
"source": [ | |
"## float: \n", | |
"- số thực: R" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "center-australian", | |
"metadata": {}, | |
"source": [ | |
"## số thực là bộ số gồm 2 bộ con:\n", | |
"### Số hữu tỷ: có thể viết ở dạng tỷ số, phân số\n", | |
"### Số vô tỷ: không thể viết ở dạng tỷ số, phân số" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 20, | |
"id": "verified-laser", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"0.3333333333333333" | |
] | |
}, | |
"execution_count": 20, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"1/3" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 21, | |
"id": "hazardous-patient", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"0.4" | |
] | |
}, | |
"execution_count": 21, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"2/5" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 22, | |
"id": "duplicate-mistake", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"2.0" | |
] | |
}, | |
"execution_count": 22, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"10/5" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "nonprofit-story", | |
"metadata": {}, | |
"source": [ | |
"## số vô tỷ: căn , pi" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 23, | |
"id": "rotary-bargain", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"import math" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 24, | |
"id": "hearing-proxy", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"1.4142135623730951" | |
] | |
}, | |
"execution_count": 24, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"math.sqrt(2)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 25, | |
"id": "settled-pressing", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"3.141592653589793" | |
] | |
}, | |
"execution_count": 25, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"math.pi" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 26, | |
"id": "yellow-debate", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"2.0" | |
] | |
}, | |
"execution_count": 26, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"2.0" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "coated-engineering", | |
"metadata": {}, | |
"source": [ | |
"## float là giá trị GẦN ĐÚNG" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 27, | |
"id": "surgical-festival", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"True" | |
] | |
}, | |
"execution_count": 27, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"1 + 1 == 2" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 28, | |
"id": "whole-vienna", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"True" | |
] | |
}, | |
"execution_count": 28, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"2 + 2 == 4" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 31, | |
"id": "compliant-donna", | |
"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": "pointed-given", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"True" | |
] | |
}, | |
"execution_count": 32, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"0.1 + 0.1 == 0.2" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 33, | |
"id": "abstract-flush", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"False" | |
] | |
}, | |
"execution_count": 33, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"0.1 + 0.1 + 0.1 == 0.3" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 34, | |
"id": "expired-cable", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"0.30000000000000004" | |
] | |
}, | |
"execution_count": 34, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"0.1 + 0.1 + 0.1" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "medical-shore", | |
"metadata": {}, | |
"source": [ | |
"## không so sánh == kiểu float " | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "incorporate-multimedia", | |
"metadata": {}, | |
"source": [ | |
"https://pymi.vn/blog/why-not-float/" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 36, | |
"id": "reserved-milwaukee", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"2.0" | |
] | |
}, | |
"execution_count": 36, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"4 / 2" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "massive-nicholas", | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 37, | |
"id": "legal-chart", | |
"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-37-9e1622b385b6>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0;36m1\u001b[0m\u001b[0;34m/\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", | |
"\u001b[0;31mZeroDivisionError\u001b[0m: division by zero" | |
] | |
} | |
], | |
"source": [ | |
"1/0" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "golden-softball", | |
"metadata": {}, | |
"source": [ | |
"## khi lấy 1 chia 0 xảy ra exception: ZeroDivisionError" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 38, | |
"id": "complex-greece", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"8.205305622772e-36" | |
] | |
}, | |
"execution_count": 38, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"1/121872364781236478163248716728346128" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 40, | |
"id": "awful-madison", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"100000000.0" | |
] | |
}, | |
"execution_count": 40, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"10e7" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 42, | |
"id": "tested-single", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"10000000000000000725314363815292351261583744096465219555182101554790400" | |
] | |
}, | |
"execution_count": 42, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"int(10e69)" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "opened-compatibility", | |
"metadata": {}, | |
"source": [ | |
"## mũ : power KHÔNG PHẢI DẤU NÀY (`^`) mà là `**`" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 43, | |
"id": "ideal-trust", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"256" | |
] | |
}, | |
"execution_count": 43, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"2 ** 8" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 44, | |
"id": "attended-portfolio", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"1000000000000000000000000000000000000000000000000000000000000000000000" | |
] | |
}, | |
"execution_count": 44, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"10 ** 69" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "passing-store", | |
"metadata": {}, | |
"source": [ | |
"## 2 to the power of 64" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 45, | |
"id": "mental-offense", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"18446744073709551616" | |
] | |
}, | |
"execution_count": 45, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"2 ** 64" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 46, | |
"id": "social-chorus", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"1.4142135623730951" | |
] | |
}, | |
"execution_count": 46, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"2 ** (1/2)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "twelve-prayer", | |
"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.8.5" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 5 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment