Coding Solutions Singapore profile picture

Coding Solutions Singapore (@codingsolutionssg)

Followers
70 followers
Following
1 following
Likes
450
Videos
84
Avg length
0:35

Python & programming help for NUS, NTU & polytechnic students. DM for help.

Playlists Liked videos

Latest videos by Coding Solutions Singapore

  • In java.time patterns, yyyy is the calendar year but YYYY is the week-based year: the year of the… – video , 178 views, duration 0:36

    2 likes 0 comments 0 shares 0 saves

    In java.time patterns, yyyy is the calendar year but YYYY is the week-based year: the year of the week a date falls in, by the locale's week rules. 29 Dec 2025 sits in the week (Sun 28 Dec to Sat 3 Jan under Singapore's Sunday-start weeks) that counts as week 1 of 2026, so ofPattern("YYYY-MM-dd")…

  • except Exception: pass catches every ordinary error, not only the one you meant. Here the key is… – video , 388 views, duration 0:36

    9 likes 0 comments 0 shares 0 saves

    except Exception: pass catches every ordinary error, not only the one you meant. Here the key is misspelt ("amount" instead of "amt"), so every row raises KeyError, the except swallows it, and the report says total: 0 with no log and no crash. Narrow the except to the error you can handle…

  • A set stores items by hash bucket, not by arrival order, so list(set(ids)) reads the buckets back… – video , 422 views, duration 0:36

    3 likes 0 comments 0 shares 0 saves

    A set stores items by hash bucket, not by arrival order, so list(set(ids)) reads the buckets back in bucket order: 12 lands in slot 4, 5 in slot 5 and 9 in slot 1, which gives [9, 12, 5]. The duplicates are gone, but so is your order. list(dict.fromkeys(ids)) also drops duplicates, and a dict…

  • int(price * 100) looks like a safe dollars-to-cents conversion, but 4.35 has no exact binary form… – video , 460 views, duration 0:36

    9 likes 0 comments 6 shares 0 saves

    int(price * 100) looks like a safe dollars-to-cents conversion, but 4.35 has no exact binary form: it is stored a hair under, so 4.35 * 100 is 434.99999999999994 and int() truncates it to 434. One cent missing from a real charge, no error, and only on some prices. Parse money into Decimal from a…

  • Not y OR not n is true for every possible answer: a y is not n, an n is not y, and anything else… – video , 500 views, duration 0:36

    11 likes 0 comments 0 shares 1 save

    Not 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…

  • Brackets alone only group an expression, so ("CS1010") is just the string "CS1010", and len()… – video , 470 views, duration 0:35

    16 likes 0 comments 0 shares 1 save

    Brackets 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…

  • str.find() returns -1 when the substring is not there, and -1 is a perfectly valid index… – video , 337 views, duration 0:35

    6 likes 0 comments 0 shares 0 saves

    str.find() returns -1 when the substring is not there, and -1 is a perfectly valid index: email[:-1] means "everything except the last character". So "sam" quietly becomes "sa" with no error. Check for -1 before you slice, or use .index(), which raises ValueError instead of handing you a number…

  • The loop variable is just a name bound to each item in turn. m = m + 5 makes m point at a NEW… – video , 296 views, duration 0:35

    3 likes 0 comments 0 shares 0 saves

    The loop variable is just a name bound to each item in turn. m = m + 5 makes m point at a NEW number; the list still holds the old one, so the bonus is computed and thrown away. Build a new list ([m + 5 for m in marks]) or write back by index (for i in range(len(marks)): marks[i] += 5). 👇 #CS1010…

  • Java evaluates + left to right, and as soon as one side is a String, + means concatenation… – video , 461 views, duration 0:36

    7 likes 0 comments 0 shares 1 save

    Java evaluates + left to right, and as soon as one side is a String, + means concatenation. "Total: " + 40 is the String "Total: 40", and "Total: 40" + 50 is "Total: 4050". Brackets force the int addition first: "Total: " + (a + b). The same expression with the numbers first, a + b + " total"…

  • for i, name in names tries to unpack EACH item into two variables. Each item is one string, so… – video , 449 views, duration 0:34

    9 likes 0 comments 0 shares 2 saves

    for 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"…

  • In Python ^ is bitwise XOR, not exponent. 5 is 101 in binary and 2 is 010, and XOR keeps the bits… – video , 499 views, duration 0:35

    11 likes 0 comments 0 shares 1 save

    In 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…

  • An if/elif chain runs the FIRST branch whose test is true and skips every branch after it. 90 is… – video , 494 views, duration 0:34

    11 likes 0 comments 0 shares 3 saves

    An 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…

  • in on a dict tests the KEYS, the same way looping over a dict gives you the keys. 90 is a value… – video , 461 views, duration 0:36

    9 likes 0 comments 0 shares 1 save

    in 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…

  • str.split(sep) always returns at least one piece: whatever sits between the separators, and an… – video , 468 views, duration 0:35

    9 likes 0 comments 0 shares 0 saves

    str.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…

  • Inheritance gives Student every METHOD Person has, but defining __init__ in Student replaces… – video , 338 views, duration 0:34

    7 likes 0 comments 0 shares 0 saves

    Inheritance gives Student every METHOD Person has, but defining __init__ in Student replaces Person.__init__ rather than adding to it. Python calls exactly one __init__, the child's, so self.name = name in the parent never runs and the attribute never exists. super().__init__(name) runs the…

  • Round brackets make a generator, not a tuple and not a list. A generator produces each value once… – video , 419 views, duration 0:35

    4 likes 0 comments 0 shares 1 save

    Round brackets make a generator, not a tuple and not a list. A generator produces each value once, on demand, and then it is exhausted: the first sum() pulls all three squares out of it, the second sum() gets nothing and returns 0. No error, just a wrong number. Square brackets build a list you…

  • String.compareTo compares character codes, not letters, and in Unicode every capital (A-Z is… – video , 475 views, duration 0:35

    13 likes 0 comments 0 shares 2 saves

    String.compareTo compares character codes, not letters, and in Unicode every capital (A-Z is 65-90) comes before every lowercase letter (a-z is 97-122). So Collections.sort puts "Zoe" ahead of "adam", and any name typed with a capital jumps the queue. String.CASE_INSENSITIVE_ORDER compares as if…

  • zip() pairs items until the SHORTER list runs out, then stops without a word. Three names and two… – video , 471 views, duration 0:35

    9 likes 0 comments 0 shares 1 save

    zip() 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…

  • Java defines % as the REMAINDER, not the mathematical modulo, and a remainder keeps the sign of… – video , 479 views, duration 0:36

    10 likes 0 comments 0 shares 1 save

    Java defines % as the REMAINDER, not the mathematical modulo, and a remainder keeps the sign of the left operand: -1 % 3 is -1, not 2. So the usual wrap-around idiom (i + n) % n works going forwards and quietly breaks going backwards, which is how a carousel or a ring buffer ends up throwing on…

  • Python sets __hash__ to None as soon as you define __eq__, and the reason is a rule, not an… – video , 464 views, duration 0:36

    9 likes 0 comments 1 share 1 save

    Python 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…

  • list.copy(), list[:] and list(x) are all SHALLOW: they build a new outer list whose slots point at… – video , 471 views, duration 0:34

    7 likes 0 comments 0 shares 2 saves

    list.copy(), list[:] and list(x) are all SHALLOW: they build a new outer list whose slots point at the same objects the original pointed at. For a flat list of numbers or strings that is fine, because you can only rebind those slots, not mutate them. For a list of lists it is not, because…

  • Every recursive function needs two things: a base case that returns a value outright, and a… – video , 325 views, duration 0:33

    3 likes 0 comments 0 shares 0 saves

    Every recursive function needs two things: a base case that returns a value outright, and a recursive case that moves toward it. This one has only the second, so n goes 3, 2, 1, 0, -1, -2 and never hits a stopping point. Python caps the call stack at about a thousand frames and raises…

  • name = name inside __init__ is a local assignment: it reads the parameter and writes it straight… – video , 471 views, duration 0:34

    7 likes 0 comments 1 share 4 saves

    name = name inside __init__ is a local assignment: it reads the parameter and writes it straight back to the same local slot, which is then thrown away when the method returns. Nothing touches the object at all. self is the object, so self.name = name is what actually stores it. Python will not…

  • Anything assigned in the class body is a CLASS attribute: it is created once, when the class is… – video , 437 views, duration 0:35

    8 likes 0 comments 0 shares 1 save

    Anything assigned in the class body is a CLASS attribute: it is created once, when the class is defined, and every instance looks at that same object. For an int or a string you rarely notice, because rebinding self.x = 5 quietly makes an instance attribute. For a list you do notice, because…

  • contains() does not compare fields, it calls equals() on your objects, and a class that does not… – video , 366 views, duration 0:35

    7 likes 0 comments 0 shares 1 save

    contains() does not compare fields, it calls equals() on your objects, and a class that does not override equals() inherits Object's version, which is reference identity. Two Points holding the same x and y are still two different objects, so contains() is false. A record generates equals()…

  • A dict finds a key by its hash, so the hash has to stay the same for as long as the key is in the… – video , 576 views, duration 0:35

    14 likes 0 comments 1 share 3 saves

    A 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…

  • if not mark: is a test for emptiness, and 0, 0.0, "", [], {} and None are all empty. So a student… – video , 327 views, duration 0:33

    5 likes 0 comments 1 share 0 saves

    if not mark: is a test for emptiness, and 0, 0.0, "", [], {} and None are all empty. So a student who genuinely scored 0 takes the same branch as a student with no record at all, and the mark is silently thrown away. This is the single most common place a real zero disappears from a dataset. When…

  • Mode "w" does not mean write, it means truncate then write. Every open() in the loop empties the… – video , 422 views, duration 0:36

    5 likes 0 comments 0 shares 1 save

    Mode "w" does not mean write, it means truncate then write. Every open() in the loop empties the file before a single character goes in, so you end up with whatever the last iteration wrote and no error to tell you the rest is gone. Open once before the loop, write inside it, close after, or use a…

  • return does two things and beginners only count one of them: it hands a value back AND it ends the… – video , 192 views, duration 0:35

    5 likes 0 comments 0 shares 1 save

    return does two things and beginners only count one of them: it hands a value back AND it ends the function immediately. Put it inside a loop and the loop runs exactly once, so you get the first match and never learn the rest exist. Nothing errors, the answer is just quietly incomplete, which is…

  • Strings in Python are immutable, so .title(), .upper(), .strip() and .replace() cannot change the… – video , 466 views, duration 0:33

    13 likes 0 comments 1 share 1 save

    Strings 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…

Showing 30 of 84 videos

Load more videos

Explore & export videos

Coding Solutions Singapore TikTok stats

Coding Solutions Singapore (@codingsolutionssg) has 70 TikTok followers as of .

Followers
70
Likes
450
Videos
84
Likes per video
5
Average video length
0:35
Median per post
461 views · 9 likes · 0 comments · 0 shares · 1 save
Average engagement per view - follower
2.0% - 0.12
Average views per follower
5.99
Most viewed recent posts
  1. “A dict finds a key by its hash, so the hash has to stay…” · 576 views · 14 likes · 0 comments ·
  2. “Not y OR not n is true for every possible answer: a y is…” · 500 views · 11 likes · 0 comments ·
  3. “In Python ^ is bitwise XOR, not exponent. 5 is 101 in…” · 499 views · 11 likes · 0 comments ·
Last post
(less than a day before this check)
Posting rate
about 3.3 posts a week
TikTok content labels
Education (19 of 19 posts), Culture & Education & Technology (19 of 19 posts)
Hashtags used most
#NUS (27), #polytechnic (27), #python (25), #CS1010 (23), #pythonbug (23)

How these numbers are counted

About Coding Solutions Singapore

Account created