#pythonbug
Hashtag
#pythonbug videos
-
– video by @mathew.storm
133 likes 1 comment 2 shares 21 saves
@mathew.stormPython Debug Daily 008 - object oriented flashcards - #learnpython #learntocode #pythondebug #pythontutorial #pythonbug
-
– video by @myrakon.lab
58 likes 1 comment 9 shares 15 saves
@myrakon.labFind the bug in the code. #Python #pythonbug #code #pythonchallenge
-
– video by @myrakon.lab
51 likes 0 comments 2 shares 7 saves
@myrakon.labPython Bug Hunt: Can you spot the math mistake? 🐛🧮 This function is supposed to calculate the total price after applying a percentage discount, but there's a flaw in how the discount is calculated! Look closely at line 27: price * (discount / 100) gives the discount amount, not the final price of…
-
– video by @it.old
24 likes 0 comments 1 share 1 save
@it.oldBắt đầu với Python? Đây là 5 lỗi bạn có thể sẽ gặp phải! #python #pythonbug #pythonerrors #laptrinh #laptrinhpython
-
– video by @codingsolutionssg
22 likes 0 comments 0 shares 1 save
@codingsolutionssg0.1 + 0.2 == 0.3 is False in Python - floats can't store those exactly, so you get 0.30000000000000004. Never compare floats with ==. Use math.isclose(). 👇 #CS1010 #python #NUS #polytechnic #pythonbug
-
– video by @codingsolutionssg
16 likes 0 comments 0 shares 1 save
@codingsolutionssgBrackets alone only group an expression, so ("CS1010") is just the string "CS1010", and len() counts its 6 characters. It is the comma that makes a tuple: ("CS1010",) is a tuple of one. Loop over the bracket-only version and you get C, S, 1, 0, 1, 0 on six lines. 👇 #CS1010 #python #NUS…
-
– video by @codingsolutionssg
14 likes 0 comments 1 share 3 saves
@codingsolutionssgA dict finds a key by its hash, so the hash has to stay the same for as long as the key is in the dict. Lists are mutable, so Python refuses to hash one at all rather than let you build a dict you could silently corrupt by appending to a key. Swap the square brackets for round ones and you have a…
-
14 likes 0 comments 2 shares 0 saves
@aeno.ai -
– video by @codingsolutionssg
13 likes 0 comments 1 share 1 save
@codingsolutionssgStrings in Python are immutable, so .title(), .upper(), .strip() and .replace() cannot change the string you called them on. They build a new string and return it, and if you do not assign that return value it is discarded the moment the line ends. There is no error because calling a method and…
-
– video by @codingsolutionssg
13 likes 0 comments 0 shares 2 saves
@codingsolutionssgif n == 1 or 2: looks right but it's always True. Python reads it as (n == 1) or (2), and 2 is truthy on its own. Write n == 1 or n == 2. Did this one get you? 👇 #CS1010 #python #NUS #polytechnic #pythonbug
-
– video by @function.factory
12 likes 0 comments 0 shares 0 saves
@function.factoryComments age. Bugs don’t. #coding #programmerlife #pythonbug #pythonfunctions
-
– video by @codingsolutionssg
11 likes 0 comments 0 shares 1 save
@codingsolutionssgNot y OR not n is true for every possible answer: a y is not n, an n is not y, and anything else is both. So the condition rejects everything, valid answers included, and nothing errors. To reject everything outside a set, join the != tests with and, or write answer not in ("y", "n"). Say it out…
-
– video by @codingsolutionssg
11 likes 0 comments 0 shares 1 save
@codingsolutionssgIn Python ^ is bitwise XOR, not exponent. 5 is 101 in binary and 2 is 010, and XOR keeps the bits that differ: 111, which is 7. No error, just a wrong number. The power operator is ** (or pow()). Java and C behave the same way, so this one follows you between languages. 👇 #CS1010 #python #NUS…
-
– video by @codingsolutionssg
11 likes 0 comments 0 shares 3 saves
@codingsolutionssgAn if/elif chain runs the FIRST branch whose test is true and skips every branch after it. 90 is at least 50, so a mark of 90 gets a C and the A branch is never even tested. With overlapping bands, order is the logic: test the highest band first and work down, or give each test both ends of its…
-
– video by @codingsolutionssg
9 likes 0 comments 0 shares 0 saves
@codingsolutionssgstr.split(sep) always returns at least one piece: whatever sits between the separators, and an empty string has one empty piece. So "".split(",") is [''], its length is 1, and an empty sign-up sheet, CSV row or input() line counts as one person. Guard it: line.split(",") if line else []. Oddly…
-
– video by @codingsolutionssg
9 likes 0 comments 0 shares 2 saves
@codingsolutionssgfor i, name in names tries to unpack EACH item into two variables. Each item is one string, so Python unpacks the string itself: "Ana" is three characters and there are two slots, hence "too many values to unpack". A two-letter name like "Al" would not even crash, it would quietly give i = "A"…
-
– video by @codingsolutionssg
9 likes 0 comments 0 shares 1 save
@codingsolutionssgin on a dict tests the KEYS, the same way looping over a dict gives you the keys. 90 is a value, so 90 in scores is False even though Ana scored exactly that, and the else branch runs with no error. Use scores.values() to search the values, or scores.items() for (key, value) pairs. Keys are the…
-
– video by @codingsolutionssg
9 likes 0 comments 0 shares 1 save
@codingsolutionssgzip() pairs items until the SHORTER list runs out, then stops without a word. Three names and two marks give you two rows, and the third student simply is not there: no error, no warning, and on a class list of thirty you will not notice one missing line. itertools.zip_longest keeps going and…
-
– video by @codingsolutionssg
9 likes 0 comments 1 share 1 save
@codingsolutionssgPython sets __hash__ to None as soon as you define __eq__, and the reason is a rule, not an accident: if a == b then hash(a) must equal hash(b), or a set could hold two equal objects and a dict could lose a key. The default __hash__ is based on identity, which would break that rule the moment your…
19 videos
Load more videosAbout #pythonbug
The 19 videos on this page were posted between and and have 11.2K views in total. The most viewed is “Python Debug Daily 008 - object oriented flashcards” by @mathew.storm (1.1K views). They come from 6 creators: @codingsolutionssg posted 13 of them and @myrakon.lab 2. The hashtags they use most are #python, #CS1010, #NUS, #polytechnic and #LearnPython. Most captions are in English.