{"id":266,"date":"2025-02-28T11:42:03","date_gmt":"2025-02-28T11:42:03","guid":{"rendered":"https:\/\/news.techjunior.vn\/?p=266"},"modified":"2025-02-28T11:42:03","modified_gmt":"2025-02-28T11:42:03","slug":"%f0%9f%90%8d%f0%9f%92%a1-nhung-loi-thuong-gap-khi-tre-em-hoc-lap-trinh-python-va-cach-khac-phuc-%f0%9f%9a%80","status":"publish","type":"post","link":"https:\/\/news.techjunior.vn\/?p=266","title":{"rendered":"\ud83d\udc0d\ud83d\udca1 NH\u1eeeNG L\u1ed6I TH\u01af\u1edcNG G\u1eb6P KHI TR\u1eba EM H\u1eccC L\u1eacP TR\u00ccNH PYTHON \u2013 V\u00c0 C\u00c1CH KH\u1eaeC PH\u1ee4C! \ud83d\ude80"},"content":{"rendered":"\n<h1 class=\"wp-block-heading\"><\/h1>\n\n\n\n<p>Python l\u00e0 m\u1ed9t ng\u00f4n ng\u1eef l\u1eadp tr\u00ecnh tuy\u1ec7t v\u1eddi cho tr\u1ebb em v\u00ec <strong>d\u1ec5 h\u1ecdc, d\u1ec5 \u0111\u1ecdc, d\u1ec5 vi\u1ebft<\/strong>. Nh\u01b0ng khi m\u1edbi b\u1eaft \u0111\u1ea7u, c\u00e1c b\u00e9 th\u01b0\u1eddng m\u1eafc m\u1ed9t s\u1ed1 l\u1ed7i ph\u1ed5 bi\u1ebfn. H\u00e3y c\u00f9ng kh\u00e1m ph\u00e1 v\u00e0 t\u00ecm c\u00e1ch s\u1eeda nh\u00e9! \ud83d\udd0d\u2728<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udea8 <strong>1. Qu\u00ean d\u1ea5u hai ch\u1ea5m (:) trong c\u00e2u l\u1ec7nh \u0111i\u1ec1u ki\u1ec7n ho\u1eb7c v\u00f2ng l\u1eb7p<\/strong><\/h3>\n\n\n\n<p>\ud83d\udd34 <strong>L\u1ed7i:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>if 5 &gt; 3\n    print(\"\u0110\u00fang r\u1ed3i!\")\n<\/code><\/pre>\n\n\n\n<p>\u26a0\ufe0f Python s\u1ebd b\u00e1o l\u1ed7i v\u00ec thi\u1ebfu d\u1ea5u <code>:<\/code> sau <code>if<\/code>.<\/p>\n\n\n\n<p>\u2705 <strong>C\u00e1ch s\u1eeda \u0111\u00fang:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>if 5 &gt; 3:\n    print(\"\u0110\u00fang r\u1ed3i!\")\n<\/code><\/pre>\n\n\n\n<p>\ud83d\udccc <strong>M\u1eb9o:<\/strong> Lu\u00f4n ki\u1ec3m tra xem <code>if<\/code>, <code>for<\/code>, <code>while<\/code>, <code>def<\/code> c\u00f3 d\u1ea5u <code>:<\/code> hay ch\u01b0a!<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udcdd <strong>2. Sai th\u1ee5t l\u1ec1 (IndentationError)<\/strong><\/h3>\n\n\n\n<p>\ud83d\udd34 <strong>L\u1ed7i:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>def xin_chao():\nprint(\"Hello!\")\n<\/code><\/pre>\n\n\n\n<p>\u26a0\ufe0f Python y\u00eau c\u1ea7u c\u00e1c l\u1ec7nh trong h\u00e0m ph\u1ea3i \u0111\u01b0\u1ee3c <strong>th\u1ee5t v\u00e0o<\/strong> \u0111\u00fang c\u00e1ch.<\/p>\n\n\n\n<p>\u2705 <strong>C\u00e1ch s\u1eeda \u0111\u00fang:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>def xin_chao():\n    print(\"Hello!\")\n<\/code><\/pre>\n\n\n\n<p>\ud83d\udccc <strong>M\u1eb9o:<\/strong> S\u1eed d\u1ee5ng <strong>4 d\u1ea5u c\u00e1ch ho\u1eb7c Tab<\/strong> \u0111\u1ec3 th\u1ee5t l\u1ec1 \u0111\u00fang chu\u1ea9n.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udd04 <strong>3. Nh\u1ea7m l\u1eabn gi\u1eefa <code>=<\/code> v\u00e0 <code>==<\/code><\/strong><\/h3>\n\n\n\n<p>\ud83d\udd34 <strong>L\u1ed7i:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>if x = 10:\n    print(\"x b\u1eb1ng 10\")\n<\/code><\/pre>\n\n\n\n<p>\u26a0\ufe0f <code>=<\/code> l\u00e0 g\u00e1n gi\u00e1 tr\u1ecb, <code>==<\/code> m\u1edbi l\u00e0 so s\u00e1nh.<\/p>\n\n\n\n<p>\u2705 <strong>C\u00e1ch s\u1eeda \u0111\u00fang:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>if x == 10:\n    print(\"x b\u1eb1ng 10\")\n<\/code><\/pre>\n\n\n\n<p>\ud83d\udccc <strong>M\u1eb9o:<\/strong> H\u00e3y \u0111\u1ecdc c\u00e2u l\u1ec7nh nh\u01b0 sau:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>=<\/code> ngh\u0129a l\u00e0 <strong>g\u00e1n gi\u00e1 tr\u1ecb<\/strong><\/li>\n\n\n\n<li><code>==<\/code> ngh\u0129a l\u00e0 <strong>so s\u00e1nh b\u1eb1ng<\/strong><\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udd22 <strong>4. L\u1eabn l\u1ed9n ki\u1ec3u d\u1eef li\u1ec7u (TypeError)<\/strong><\/h3>\n\n\n\n<p>\ud83d\udd34 <strong>L\u1ed7i:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>age = input(\"Nh\u1eadp tu\u1ed5i: \")\nprint(\"N\u0103m sau b\u1ea1n s\u1ebd l\u00e0 \" + age + 1)\n<\/code><\/pre>\n\n\n\n<p>\u26a0\ufe0f <code>input()<\/code> lu\u00f4n tr\u1ea3 v\u1ec1 <strong>chu\u1ed7i<\/strong>, kh\u00f4ng th\u1ec3 c\u1ed9ng tr\u1ef1c ti\u1ebfp v\u1edbi s\u1ed1!<\/p>\n\n\n\n<p>\u2705 <strong>C\u00e1ch s\u1eeda \u0111\u00fang:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>age = int(input(\"Nh\u1eadp tu\u1ed5i: \"))\nprint(\"N\u0103m sau b\u1ea1n s\u1ebd l\u00e0 \" + str(age + 1))\n<\/code><\/pre>\n\n\n\n<p>\ud83d\udccc <strong>M\u1eb9o:<\/strong> Chuy\u1ec3n \u0111\u1ed5i ki\u1ec3u d\u1eef li\u1ec7u khi c\u1ea7n (<code>int()<\/code>, <code>str()<\/code>, v.v.).<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udd0d <strong>5. Qu\u00ean khai b\u00e1o bi\u1ebfn tr\u01b0\u1edbc khi s\u1eed d\u1ee5ng<\/strong><\/h3>\n\n\n\n<p>\ud83d\udd34 <strong>L\u1ed7i:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>print(name)\n<\/code><\/pre>\n\n\n\n<p>\u26a0\ufe0f Python s\u1ebd b\u00e1o <strong>NameError<\/strong> v\u00ec bi\u1ebfn <code>name<\/code> ch\u01b0a \u0111\u01b0\u1ee3c t\u1ea1o.<\/p>\n\n\n\n<p>\u2705 <strong>C\u00e1ch s\u1eeda \u0111\u00fang:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>name = \"Alice\"\nprint(name)\n<\/code><\/pre>\n\n\n\n<p>\ud83d\udccc <strong>M\u1eb9o:<\/strong> Lu\u00f4n g\u00e1n gi\u00e1 tr\u1ecb cho bi\u1ebfn tr\u01b0\u1edbc khi s\u1eed d\u1ee5ng!<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udc22 <strong>6. Vi\u1ebft sai t\u00ean bi\u1ebfn, h\u00e0m, module<\/strong><\/h3>\n\n\n\n<p>\ud83d\udd34 <strong>L\u1ed7i:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import turle  \nturle.forward(100)\n<\/code><\/pre>\n\n\n\n<p>\u26a0\ufe0f <strong>turle<\/strong> sai ch\u00ednh t\u1ea3! T\u00ean \u0111\u00fang ph\u1ea3i l\u00e0 <code>turtle<\/code>.<\/p>\n\n\n\n<p>\u2705 <strong>C\u00e1ch s\u1eeda \u0111\u00fang:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import turtle  \nturtle.forward(100)\n<\/code><\/pre>\n\n\n\n<p>\ud83d\udccc <strong>M\u1eb9o:<\/strong> Ki\u1ec3m tra k\u1ef9 ch\u00ednh t\u1ea3 khi nh\u1eadp t\u00ean bi\u1ebfn, h\u00e0m v\u00e0 th\u01b0 vi\u1ec7n!<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\ude80 <strong>L\u1edcI K\u1ebeT<\/strong><\/h3>\n\n\n\n<p>\ud83c\udf1f L\u1eadp tr\u00ecnh Python r\u1ea5t th\u00fa v\u1ecb, nh\u01b0ng ai c\u0169ng c\u00f3 th\u1ec3 m\u1eafc l\u1ed7i! \u0110i\u1ec1u quan tr\u1ecdng l\u00e0:<br>\u2705 <strong>Ki\u1ec3m tra l\u1ed7i k\u1ef9 c\u00e0ng<\/strong> tr\u01b0\u1edbc khi ch\u1ea1y ch\u01b0\u01a1ng tr\u00ecnh.<br>\u2705 <strong>\u0110\u1ecdc l\u1ed7i do Python b\u00e1o<\/strong> \u0111\u1ec3 hi\u1ec3u v\u00e0 s\u1eeda nhanh h\u01a1n.<br>\u2705 <strong>Th\u1ef1c h\u00e0nh th\u01b0\u1eddng xuy\u00ean<\/strong> \u0111\u1ec3 tr\u00e1nh nh\u1eefng l\u1ed7i n\u00e0y!<\/p>\n\n\n\n<p>\ud83d\udcac <strong>B\u1ea1n ho\u1eb7c b\u00e9 nh\u00e0 b\u1ea1n \u0111\u00e3 t\u1eebng m\u1eafc l\u1ed7i n\u00e0o khi h\u1ecdc Python ch\u01b0a? B\u00ecnh lu\u1eadn chia s\u1ebb nh\u00e9!<\/strong> \u2b07\ufe0f\u2b07\ufe0f\u2b07\ufe0f<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Python l\u00e0 m\u1ed9t ng\u00f4n ng\u1eef l\u1eadp tr\u00ecnh tuy\u1ec7t v\u1eddi cho tr\u1ebb em v\u00ec d\u1ec5 h\u1ecdc, d\u1ec5 \u0111\u1ecdc, d\u1ec5 vi\u1ebft. Nh\u01b0ng khi m\u1edbi b\u1eaft \u0111\u1ea7u, c\u00e1c b\u00e9 th\u01b0\u1eddng m\u1eafc m\u1ed9t s\u1ed1 l\u1ed7i ph\u1ed5&#8230;<\/p>\n","protected":false},"author":6,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-266","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/news.techjunior.vn\/index.php?rest_route=\/wp\/v2\/posts\/266","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/news.techjunior.vn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/news.techjunior.vn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/news.techjunior.vn\/index.php?rest_route=\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/news.techjunior.vn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=266"}],"version-history":[{"count":1,"href":"https:\/\/news.techjunior.vn\/index.php?rest_route=\/wp\/v2\/posts\/266\/revisions"}],"predecessor-version":[{"id":267,"href":"https:\/\/news.techjunior.vn\/index.php?rest_route=\/wp\/v2\/posts\/266\/revisions\/267"}],"wp:attachment":[{"href":"https:\/\/news.techjunior.vn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=266"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/news.techjunior.vn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=266"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/news.techjunior.vn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=266"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}