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.
Latest videos by Coding Solutions Singapore
-
– video
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")…
-
– video
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…
-
– video
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…
-
– video
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…
-
– video
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…
-
– video
16 likes 0 comments 0 shares 1 save
-
– video
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…
-
– video
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…
-
– video
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"…
-
– video
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"…
-
– video
11 likes 0 comments 0 shares 1 save
-
– video
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…
-
– video
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…
-
– video
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…
-
– video
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…
-
– video
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…
-
– video
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…
-
– video
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…
-
– video
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…
-
– video
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…
-
– video
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…
-
– video
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…
-
– video
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…
-
– video
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…
-
– video
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()…
-
– video
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…
-
– video
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…
-
– video
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…
-
– video
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…
-
– video
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 videosExplore & export videos
Uses the videos loaded on this page. Load more to include older ones.
Videos by month
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
- “A dict finds a key by its hash, so the hash has to stay…” · 576 views · 14 likes · 0 comments ·
- “Not y OR not n is true for every possible answer: a y is…” · 500 views · 11 likes · 0 comments ·
- “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)
About Coding Solutions Singapore
Account created