Skip to main content

Posts

Showing posts from October, 2021

Python quick bite 01 - Scope

Summary of Scope (lesson learnt from 100 Days of Code, Day 12) There is the local scope and global scope for variables.  Global scope refers to variables that we assigned in our codes. Local scope refers to variables that we assign or use within a function.  In a function, if no variable is defined, the global scope version will be used.  eg 1. coffee_drink = "long black" def cuppa():    print("Drink inside cuppa function:", coffee_drink) cuppa() print("Drink outside cuppa function:", coffee_drink) This will return you: Drink inside cuppa function: long black Drink outside cuppa function: long black However, if you had defined a coffee_drink in the function, that coffee_drink is only callable within the function.  eg 2.  def cuppa():      coffee_drink = "latte"      print("Drink inside cuppa function:", coffee_drink) cuppa() print("Drink outside cuppa function:", coffee_drink) This will return you: Drink inside cuppa function:

3 learning apps that I had been using (LinkedinLearning, Duolingo, Tigerhall) Updated on 3Jan22

Linkedin Learning At my BCG RISE programme, I was taught quite a bit of content through LinkedIn Learning. I am very impressed with the content, there are so many instructors and a wide variety of courses available. For the programme, we did career-related courses like how to write your resume or answer interview questions. There are also skill-related ones like Microsoft excel skills. The programme gave us free access to Linkedin Learning during the course. It will cost you a certain amount depending on your subscription and the perk will be that you can record any course that you had completed in Linkedin Learning under your Linkedin profile. It will appear under the "License and Certification" tab.  After I found out how useful this LinkedIn learning is, I got quite concerned about the cease of my access rights after my programme ends in Jan 2022.  I searched around and managed to secure two ways to access Linkedin Learning. However, these two methods will not allow me to

My attempt (8) at learning a coding language (SQL) in my mid 30s

This is the last post for SQL coding as I finished the 9 hours of video recording in the Udemy course. Very impressed that I had been so motivated to complete the course such that I had been attempting to do an hour or two everyday.  Harlsten, CC BY-SA 4.0 <https://creativecommons.org/licenses/by-sa/4.0>, via Wikimedia Commons This section was about: CASE, COALESCE, CAST, NULLIF, VIEW 1) CASE - only execute SQL code when certain conditions are met. Similar to IF/ELSE statements. There are two ways to use CASE as shown in the general syntax or an expression syntax.  eg1. (general syntax) SELECT column1 , CASE        WHEN condition1 THEN result1        WHEN condition2 THEN result2        ELSE other_result AS new_name(this will rename the returned result column when the conditions are met) END FROM table; eg1a. (general syntax) CASE      WHEN (id < = 5) THEN 'Gold member'     WHEN (id between 5 and 10 THEN 'Silver member'     ELSE 'Green member' END AS cus

My attempt (7) at learning a coding language (SQL) in my mid 30s

Onwards to creating a database! Understanding 1: Setting data type for each data to be stored.  These are pretty similar like other coding languages. There are the boolean (true/false), character(char,varchar(no of characters) and text), numeric(integer/float), temporal(date,time,timestamp). Not as common ones are UUID (universally unique identifiers, a unique code to identify the row), array(stores a list of strings or numbers), JSON(a data table file), Hstore key-value pair, network address and geometric data.  Bymbabymba, CC BY-SA 4.0 <https://creativecommons.org/licenses/by-sa/4.0>, via Wikimedia Commons eg. To store phone number. Consideration should extend to what do we do with phone numbers. Since we do not need to perform mathematical calculations on them, it is easier to store as text-based data type. And this also avoids the issue that 2 and 02 have the same numerical values but can mean a totally different phone number in terms of area code.  It is good to google the b

My attempt (6) at learning a coding language (SQL) in my mid 30s

I have moved on to advanced SQL topics! Woo~ And these are the things i will be looking at: 1) Time stamps and Extract 2) String Functions 3) Sub-query 4) Self-Join pgAdmin Community, CC BY-SA 3.0 <https://creativecommons.org/licenses/by-sa/3.0>, via Wikimedia Commons 1) Time stamps are more useful when creating our own tables and databases rather than when querying a database.  The different data type for date and time: Time - contains only time Date - contains only date Timestamp - contains date and time Timestamptz - contains date, time and timezone We may not always need the full level of timetamptz and for example we may only need to work with or compute the number of hours which means we do not need time zone information. It is important to take note that we can always remove data like time zone but we cannot add in the information later since we had never recorded them in the first place.  Very useful for populating the table. SHOW ALL - show all the parameters as you conn