Created
May 20, 2022 02:11
-
-
Save hvnsweeting/d6cef8f124724d6681cfa555fb1cf0c2 to your computer and use it in GitHub Desktop.
Học Python tại Hà Nội/ TP HCM/ Sài Gòn 2022 tháng 5 lớp Pymi.vn buổi 1
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": "eb43265d", | |
"metadata": {}, | |
"source": [ | |
"# PYmi" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "4f6a2fa0", | |
"metadata": {}, | |
"source": [ | |
"# Welcome to pymi.vn" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "464f9a0f", | |
"metadata": {}, | |
"source": [ | |
"https://pp.pymi.vn/article/dh/" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "dadfa467", | |
"metadata": {}, | |
"source": [ | |
"## projecteuler.net\n", | |
"https://projecteuler.net/problem=1\n", | |
"Multiples of 3 or 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": "1e0ed79a", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"233168" | |
] | |
}, | |
"execution_count": 1, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"sum(i for i in range(0, 1000)\n", | |
" if i % 3 == 0 or i % 5 == 0)" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "fdab4da0", | |
"metadata": {}, | |
"source": [ | |
"## bat python" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "f7745590", | |
"metadata": {}, | |
"source": [ | |
"Go python3, windows bat powershell go python" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "8676edb1", | |
"metadata": {}, | |
"source": [ | |
">>> " | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "c76a58db", | |
"metadata": {}, | |
"source": [ | |
"## prompt - chờ gõ biểu thức" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"id": "6da81a2e", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"12312" | |
] | |
}, | |
"execution_count": 1, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"12312" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"id": "886b3119", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"12" | |
] | |
}, | |
"execution_count": 2, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"12" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"id": "c3b606c6", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"-123123" | |
] | |
}, | |
"execution_count": 3, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"-123123" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 4, | |
"id": "5af3dce0", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"0" | |
] | |
}, | |
"execution_count": 4, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"0" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "cea8e1c2", | |
"metadata": {}, | |
"source": [ | |
"## phép cộng: plus, add" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 5, | |
"id": "a0989ae8", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"2" | |
] | |
}, | |
"execution_count": 5, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"1+1" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 6, | |
"id": "c3c12263", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"4" | |
] | |
}, | |
"execution_count": 6, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"2 + 2" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 10, | |
"id": "f04508c0", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"23456654456554345454543454613566697867897777897797779777775777666666664" | |
] | |
}, | |
"execution_count": 10, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"23456654456554345454543454567887909098909878987898789878787878878787877+45678788768987898909898989898987898787878787" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 11, | |
"id": "9249196a", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"2345665445655434545454345461356669786789777789779777977777577766666666423456654456554345454543454613566697867897777897797779777775777666666664234566544565543454545434546135666978678977778977977797777757776666666642345665445655434545454345461356669786789777789779777977777577766666666423456654456554345454543454613566697867897777897797779777775777666666664234566544565543454545434546135666978678977778977977797777757776666666644691330891310869090908690922713339573579555579559555955555155533333332846913308913108690909086909227133395735795555795595559555551555333333328469133089131086909090869092271333957357955557955955595555515553333333284691330891310869090908690922713339573579555579559555955555155533333332846913308913108690909086909227133395735795555795595559555551555333333328469133089131086909090869092271333957357955557955955595555515553333333284691330891310869090908690922713339573579555579559555955555155533333332846913308913108690909086909227133395735795555795595559555551555333333328" | |
] | |
}, | |
"execution_count": 11, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"2345665445655434545454345461356669786789777789779777977777577766666666423456654456554345454543454613566697867897777897797779777775777666666664234566544565543454545434546135666978678977778977977797777757776666666642345665445655434545454345461356669786789777789779777977777577766666666423456654456554345454543454613566697867897777897797779777775777666666664234566544565543454545434546135666978678977778977977797777757776666666642345665445655434545454345461356669786789777789779777977777577766666666423456654456554345454543454613566697867897777897797779777775777666666664 + 2345665445655434545454345461356669786789777789779777977777577766666666423456654456554345454543454613566697867897777897797779777775777666666664234566544565543454545434546135666978678977778977977797777757776666666642345665445655434545454345461356669786789777789779777977777577766666666423456654456554345454543454613566697867897777897797779777775777666666664234566544565543454545434546135666978678977778977977797777757776666666642345665445655434545454345461356669786789777789779777977777577766666666423456654456554345454543454613566697867897777897797779777775777666666664234566544565543454545434546135666978678977778977977797777757776666666642345665445655434545454345461356669786789777789779777977777577766666666423456654456554345454543454613566697867897777897797779777775777666666664234566544565543454545434546135666978678977778977977797777757776666666642345665445655434545454345461356669786789777789779777977777577766666666423456654456554345454543454613566697867897777897797779777775777666666664" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "0dd75876", | |
"metadata": {}, | |
"source": [ | |
"## LỚP KẾT LUẬN: CỘNG THOẢI MÁI" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "a83b01f4", | |
"metadata": {}, | |
"source": [ | |
"## PHÉP TRỪ: MINUS , SUBTRACT" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 12, | |
"id": "5be78bb6", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111" | |
] | |
}, | |
"execution_count": 12, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 13, | |
"id": "d74ff4d6", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"-123122" | |
] | |
}, | |
"execution_count": 13, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"\n", | |
"1- 123123" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "8c6804d8", | |
"metadata": {}, | |
"source": [ | |
"## TRỪ THOẢI MÁI " | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "4e63cb89", | |
"metadata": {}, | |
"source": [ | |
"## NHÂN: MULTIPLY *" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 14, | |
"id": "bcc34731", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"10" | |
] | |
}, | |
"execution_count": 14, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"5 * 2" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 17, | |
"id": "54166523", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"563881194554211660170313463067962450300034039338598295971195629938084421194862325603057491104495307992381238632071734628538508942762217632035777791090895132790743599363602594769237500832741173059292250544198596069589257596906704422456472813771521542843191969610291568789120768343612676062424855014089193096015953507106780565274899902150727995507265294595488806429839538214638941917987851292108536968886135647833310944624303533643095381844983177243009046347785643249387507640157115492363026521792218923683078199650668382141826502011290861539238358978752798100082480068935477065675289066738201751475900878480020751468025819659349470379486341233493540714496549852379316888483446491193462641113376981159582833276963303285383257176872438747681820927748722450240301604676153708031415916711636215488552210843264788073905855102740694694395407115877300622003904185984053356972990527579385342229809789863727440526946742870848406920098132211918375484072780316259085921727805109269827347127354767747983364238902670210628697667790958737455569729441343852268260010514267657471556861566664166675324193254879314722993666690904383203374261548812326460192346301039827106007760969318062101802351164133387458936705740347818437007222428406431709731454888942669377932844347411752579233574310349505514344585418033418532165972643207323540473609489157914097451425146409564648867717497397497830558597208677525037448607900358591597467977639858518812546606096740013907623441196453388023242215762086806844911840705489479182382185017222292747956176564015604054279382576390100472828257908328987034026343055092615003885941509756864011442847117518272494609218661502462025138872577504460062428634731852290599303340318167066393540331345837868471942288588812654421718950644667701355054536091866948940476670554855551588021330246845570905827664294096767058905130699624776398827310263837531567723671469246221488819111799835724493427297601480309490719721591829221448744827833847009952826320008599355475989551966307083368048083427656607749632054791317145346416599537766790030891295192595388802485630987280509857711125347624296331130819788201662629273143570971241369854084835233948743375237951284962662619085030163456" | |
] | |
}, | |
"execution_count": 17, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"23746182736478123467812364876123842374618273647812346781236487612384237461827364781234678123648761238423746182736478123467812364876123842374618273647812346781236487612384237461827364781234678123648761238423746182736478123467812364876123842374618273647812346781236487612384237461827364781234678123648761238423746182736478123467812364876123842374618273647812346781236487612384237461827364781234678123648761238423746182736478123467812364876123842374618273647812346781236487612384237461827364781234678123648761238423746182736478123467812364876123842374618273647812346781236487612384237461827364781234678123648761238423746182736478123467812364876123842374618273647812346781236487612384237461827364781234678123648761238423746182736478123467812364876123842374618273647812346781236487612384237461827364781234678123648761238423746182736478123467812364876123842374618273647812346781236487612384237461827364781234678123648761238423746182736478123467812364876123842374618273647812346781236487612384237461827364781234678123648761238423746182736478123467812364876123842374618273647812346781236487612384 * 23746182736478123467812364876123842374618273647812346781236487612384237461827364781234678123648761238423746182736478123467812364876123842374618273647812346781236487612384237461827364781234678123648761238423746182736478123467812364876123842374618273647812346781236487612384237461827364781234678123648761238423746182736478123467812364876123842374618273647812346781236487612384237461827364781234678123648761238423746182736478123467812364876123842374618273647812346781236487612384237461827364781234678123648761238423746182736478123467812364876123842374618273647812346781236487612384237461827364781234678123648761238423746182736478123467812364876123842374618273647812346781236487612384237461827364781234678123648761238423746182736478123467812364876123842374618273647812346781236487612384237461827364781234678123648761238423746182736478123467812364876123842374618273647812346781236487612384237461827364781234678123648761238423746182736478123467812364876123842374618273647812346781236487612384237461827364781234678123648761238423746182736478123467812364876123842374618273647812346781236487612384" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "2af50634", | |
"metadata": {}, | |
"source": [ | |
"## nhân thoải mái " | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "b2a51b96", | |
"metadata": {}, | |
"source": [ | |
"## phép chia: divide " | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "2b35904b", | |
"metadata": {}, | |
"source": [ | |
"# / " | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "bc46f249", | |
"metadata": {}, | |
"source": [ | |
"## /\n", | |
"- Hằng: ??? xuộc\n", | |
"- Nhu: xoạc chéo\n", | |
"- Huyền: gạch chéo" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "4d48661c", | |
"metadata": {}, | |
"source": [ | |
"## \\ " | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "5f984b04", | |
"metadata": {}, | |
"source": [ | |
"- Hằng: huyền\n", | |
"- Nhu: chéo trái \n", | |
"- Huyền: gạc " | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "5359d9be", | |
"metadata": {}, | |
"source": [ | |
"## slash /" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "f808f8e2", | |
"metadata": {}, | |
"source": [ | |
"# backslash /" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 18, | |
"id": "a031a218", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"2.0" | |
] | |
}, | |
"execution_count": 18, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"4/2" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 19, | |
"id": "3fb04f9e", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"2" | |
] | |
}, | |
"execution_count": 19, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"1+1" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "320f67f2", | |
"metadata": {}, | |
"source": [ | |
"## data type" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 20, | |
"id": "09ff07cd", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"int" | |
] | |
}, | |
"execution_count": 20, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"type(1)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 21, | |
"id": "52f290c2", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"int" | |
] | |
}, | |
"execution_count": 21, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"type(2)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 22, | |
"id": "1f6a114b", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"int" | |
] | |
}, | |
"execution_count": 22, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"type(1+1)" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "005c10ac", | |
"metadata": {}, | |
"source": [ | |
"## integer" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 23, | |
"id": "3a8de2d5", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"float" | |
] | |
}, | |
"execution_count": 23, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"type(4/2)" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "207c4b22", | |
"metadata": {}, | |
"source": [ | |
"## English" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "ebb528c7", | |
"metadata": {}, | |
"source": [ | |
"## float - ???" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "37fbc3f4", | |
"metadata": {}, | |
"source": [ | |
"Pronunciation /fləʊt/ " | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "3d88b57b", | |
"metadata": {}, | |
"source": [ | |
"## cache" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "2aee2d04", | |
"metadata": {}, | |
"source": [ | |
"Pronunciation /kaʃ/ " | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "01be6504", | |
"metadata": {}, | |
"source": [ | |
"## cash" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "2c0067ff", | |
"metadata": {}, | |
"source": [ | |
"## resort" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "ea5dc691", | |
"metadata": {}, | |
"source": [ | |
"Pronunciation /rɪˈzɔːt/ " | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "63d5109a", | |
"metadata": {}, | |
"source": [ | |
"## suite" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "e310f74f", | |
"metadata": {}, | |
"source": [ | |
"Pronunciation /swiːt/ " | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "6bac2715", | |
"metadata": {}, | |
"source": [ | |
"## sweet" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "9557cdde", | |
"metadata": {}, | |
"source": [ | |
"## python" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 24, | |
"id": "6512948c", | |
"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/tmp/ipykernel_341302/2354412189.py\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": "a53b4ecb", | |
"metadata": {}, | |
"source": [ | |
"## khi lấy 1 chia 0, xảy ra exception ZeroDivisionError" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "0724b2a9", | |
"metadata": {}, | |
"source": [ | |
"## chia" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 25, | |
"id": "3603a145", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"2.0" | |
] | |
}, | |
"execution_count": 25, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"4/ 2" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "345ad502", | |
"metadata": {}, | |
"source": [ | |
"## float" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 26, | |
"id": "2eb427b3", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"0.2" | |
] | |
}, | |
"execution_count": 26, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"0.1 + 0.1" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 27, | |
"id": "2282636e", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"True" | |
] | |
}, | |
"execution_count": 27, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"0.1 + 0.1 == 0.2" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 28, | |
"id": "e329c31c", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"False" | |
] | |
}, | |
"execution_count": 28, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"1 + 1 == 3" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "726afbed", | |
"metadata": {}, | |
"source": [ | |
"## " | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "6fbe9211", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"0.1 + 0.1 + 0.1 == 0.3 " | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 29, | |
"id": "7c3b857f", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"0.30000000000000004" | |
] | |
}, | |
"execution_count": 29, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"0.1 + 0.1 + 0.1\n" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "beb7c061", | |
"metadata": {}, | |
"source": [ | |
"https://pymi.vn/blog/why-not-float/" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "f08fd988", | |
"metadata": {}, | |
"source": [ | |
"## float - số thực?" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "8832df88", | |
"metadata": {}, | |
"source": [ | |
"## số thực = tấp số { số hữu tỷ + số vô tỷ }" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "728018b9", | |
"metadata": {}, | |
"source": [ | |
"## hữu ttỷ: viết được ở dnạg phana số - có tỷ lệ \n", | |
"## ko viết dc ở dạng phana số" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "aae2d899", | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 31, | |
"id": "7037ebf0", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"import math" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 32, | |
"id": "b3bc574f", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"3.141592653589793" | |
] | |
}, | |
"execution_count": 32, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"math.pi" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 33, | |
"id": "2ef7aec1", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"1.4142135623730951" | |
] | |
}, | |
"execution_count": 33, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"math.sqrt(2)" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "d8bc2d0b", | |
"metadata": {}, | |
"source": [ | |
"## float - kiểu dữ liệu biểu diên GẦN ĐÚNG" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "32a81491", | |
"metadata": {}, | |
"source": [ | |
"0.1 " | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 34, | |
"id": "4e3af76e", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"x = 0.1 " | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 35, | |
"id": "dc479d7a", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"(3602879701896397, 36028797018963968)" | |
] | |
}, | |
"execution_count": 35, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"x.as_integer_ratio()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 36, | |
"id": "132801a4", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"(3602879701896397, 36028797018963968)" | |
] | |
}, | |
"execution_count": 36, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"x.as_integer_ratio()" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "f718522d", | |
"metadata": {}, | |
"source": [ | |
"## kết luận: không so sánh bằng với float" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "89cc4167", | |
"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