Python: Introduction I

It has been a while I stopped learning Python from DataCamp due to my part time classes and assignment, and work commitment. It is not easy to keep track each of them everyday. On top of it, I still have my volunteer work with TechLadies and regularly have to meet up to brainstorm and updates each other.

Today’s topic is very much on Python, definitely. I want to concentrate on my writing in Python for next 2 weeks before I head off for an holiday. I am sure, I will be lazy after my break. It would be great if I can write up something to summarize or reorganize what I have been writing for the past few months on my Python’s learning using DataCamp and Udemy.

Remember my very first day I started learning Python using Udemy, it taught about the installation and I went on to install IntelliJ. Till to date, I hardly using it, most of my time, I am using the online version of Jupyter Notebook. I find it pretty easy to be used. I understood that there are many other IDEs in the market and there is no specific software to be used to code Python. For now, I will just keep it simple for my learning.

How to begin?

After the installation of the python 3, I open the terminal (in Linux) or command prompt (Windows) to go into the Python’s shell by typing the following command:


From the terminal or command prompt screen, I can see a return message from Python with the version number. There are Python 2 and Python 3. So, be clear on which version is being used on the machine because the syntax are slightly different from each others.

Checking version

On the very first time, we always want to know if everything we installed for Python works or not. Checking the version, if it is updated, latest and correct version to be used is first time we might want to do with:

python --version

Simple open up your terminal or command line to type the above command on it. On the screen, it may return you the version info such as below:

Python 3.7.0

print(‘Hello World’)

Next, we always start with simple print statement using the built-in function named print() to print out some lines, most often we will print in our first line is “Hello World”. Really, most people who first started learning programming language will have this line printed. I use this function everywhere in my coding and it is very useful. It is just same as the PRINT statement from the SQL server, if you are coming from database background. Using single quote or double quote is not a matter.

print('Hello World!')
print("Hello World!")

Variables and Types

Then, we touch on the variables and types, the important component in most programming languages. Variables and types are interrelated. I discussed about the characteristic of a variable in my first post. Let me have it here too!

  • Specific and case-sensitive name, best practice to use lowercase.
  • Define things that are subject to change.
  • Can be used to store texts, numbers or dates.
  • Cannot start with number.
  • Cannot use space  and symbols in the name, use _ instead.

Then, there are plenty of different data types as well, yes, that is the types I meant here. Remember, different types have different behaviours. I wrote many posts about each of them before. I will link them up whenever we re-visit the topic.

  • Boolean operations: and, or, not (True, False)
  • Numeric types: int, float, complex (number, decimal)
  • Text sequence type: str (string)
  • Sequence type: list, tuple, range
  • Mapping type: dict 
  • Sets type: set
  • None is frequently used to represent the absence of a value, as when default arguments are not passed to a function. It is a null value or no value at all which is different than empty string, 0 or False.

The simplest way to demonstrate how we can create a variable and assign a value to it.

height = 1.67
weight = 180

name = 'Joanne'
gender = 'Female'

isStudent = True

The above shows the height and weight variables in float and int data type, then we have name and gender in string and a variable called isStudent with a Boolean value. In Python, it does not require to declare a variable with any prefix in front of or behind the variable which we can see in Javascript or SQL Server, if you are familiar with those languages. Then, you may ask how does compiler (computer) knows it is of what type of data types.

What is the difference between (=) and (==)?

The single equal sign (=) assigns the value on the right to a variable on the left whereas the double equal sign (==) tests if the two things have the same value. The two things can be a comparison of two variables or a variable with a math operator.



type() is a built-in function which allows us to check the data types of the variables we created with assigned values. type() helps to answer the above question.

That completed the fundamental and basic to code in Python. Now, you know how to do the following:

  • use the print() statement to print texts.
  • use of variables and data types.
  • use the type() statement to print out the data type of a variable.

Probably, now you want to know what is integer, string, Boolean and etc. I have some links here to help out the basic explanation together with examples:

To talk about numbers and strings, it can be another topics by its own as there are many interesting about them such as the use of (+) sign. It is concatenate sign which means it combines two or more variables of same type together. The way number and string use (+) sign also difference than each other. Also, we have to remember that in Python, string and integer cannot use of (+) sign together. It throws exception (error). Exception is a programming jargon means error. There is a topic of exception handling in Python too. In this case, there is string formatting and integer formatting.

Let us move into fundamental part two, Python List.

Python Collections

It is an interesting topic and important part in Python. Almost everyone of us will use Python List in our daily coding life 🙂 It is a collection of values and allows to have different types within the elements, one of the most simplest and easiest collections. When it comes to the word “collection”, Python has four type of collections.

You can read more about the basic of these collection here. Each of them has different characteristics, syntax, structure and usage. Along the way, we use different collections to explain the Python codes and concepts. Below is an example of how list looks like:

fruits = ['orange', 'apple', 'pear', 'banana', 'kiwi', 'apple', 'banana']

Declaring a list is same as declare a variable, it just requires to follow the list’s syntax to create one. As mentioned earlier, it can be any data types in a list. So, you can declare a list as below too:

family = ['Anna', 1.73, 'Eddie', 1.68, 'Mother', 1.71, 'Father', 1.89]

We can use the lists above to work with control flows, going through the iteration and/or condition checking, then calculate a value and return a result. I think I will cover it in the next post.

Up to now, this portion is still a basic Python and does not involve any analytics or data science work if you are looking for one.

Short Break

I took a short break from writing and posting the stuffs I recently learned such as the Python and R languages. Both are awesomely good and interesting. I attended the R language workshops recently, I was taught to learn using the plotly.js for data visualization, one of the leaders in data science. Hope, I will start learning the data visualization on my own, juggling between Python and R. So far, I have not been exposed to visualization in Python, I am not sure how does it works.

I had a short talk with the workshop’s instructor on the last day, she mentioned about Scala is also being used for analytics. Well, my current job uses it but I never learned it well. I asked her whether she would pick up Scala, she did not say ‘No’ but at least not for now.

Looking back the past weeks after I started posting the Python and R languages’ posts, both entries have equally numbers of audiences and that showed me both languages are important for people who want to learn data analytics.

For myself, I will concentrate on one language first, get the foundation before moving forward to another language and hope I can learn and develop something from it. It has been a while I did not code like a developer 🙂

What do you think?

Next month, I might have something to come up with another topic as I needed to pick up MongoDB again for my upcoming project.

So You Want To Be A Developer? [Part 1]

As soon as the sharing session of the “So You Want to be A Developer?” at Google SIngapore’s office completed last week, I have the intention of writing my experiences as a girl in IT industry. I would love to share my experiences, from how I started until where I am today. It is not something big to be shared but it is good to be shared and I would love to hear some feedback.

I took the opportunity to attend the session (also skipping my monthly SQL meetup at Microsoft Singapore’s office) because I wish to know how is the developer nowadays. I was a software developer after a year completed my Degree in Computer Science, majoring Web Development. It was a short stint being a developer, before I moved on to be a Database Administrator cum Developer and now, I am upgrading my skills to be a Data Analyst or Data Scientist one day.

The first question the host threw to the speakers of the day was, how did you get started?

As a student who just finished her O-Level and did not know much except Mathematics and Accounts, it was quite obvious that people would think that this girl most likely would be going for Accounting or Business Administration course. I wanted something different but I did not want to be a chemist as my lifetime career. It was another subject that I loved so much in school back then.

Without waiting for my final result, I enrolled myself into a college to start of my journey in IT course. I was not good in computing, both hardware and software. I felt fear whenever touching them. And, I think that is the reason why I chose IT. Learn something that I do not know.

Two months after, I dropped out from the college. Haha. It was not because I could not cope it. I transferred to another college because I thought, if I were to graduate from a prestigious college or university, I would have higher chances of getting hired. Not only that, I did a apply for a scholarship, went for the interview and subsequently I got it from the same college I was studying. It was a wonderful moment, right.

From there, I started to learn how to code and my first programming language was C. The book C How to Program was my best pal. I still remember the first assignment was to build a console application that rolls the numbers (dices) and add the numbers together. It was so much fun trying to make the application works, debugging the bugs, and displaying the result in the black-and-white console screen.

That is how I got started.

How about you?