The First Checkpoint: Learning Python

Manali Shinde
One Datum At A Time
5 min readFeb 1, 2018

--

Why Python?

While initially starting with Python was frustrating…which I believe is the case with any programming language in the beginning, Python was easier to to pick up for a beginner. The code, and the coding rules just make sense.

First and foremost, I downloaded Anaconda navigator to use Python in the Jupyter notebook. Can I just gush about Jupyter notebooks for a quick second? It’s clean, feels comfortable and is easily exported for online submissions (which I must do for my classes). Thus, if anyone reading this feels like they want to learn Python, be sure to go to this site to download Anaconda and use the Jupyter Notebooks.

Note: All the examples are of my own creation, done in Jupyter Notebook, and screen grabbed to showcase in this article.

Things I’ve Learnt So Far:

a) The Basics: Strings, Integers, Simple Mathematics and the print() function

In every python book, guide, and course. We started off with the basics to learning the code. Working with the latest — Python 3, it was first important to learn the difference between strings and integers.

Python String

If you may not know strings are the text/words that are typed into Python. They are usually written with quotation marks for Python to interpret them. For example, below you will find an example of a string:

Python Simple Mathematics and Float/Integer Example

Python 3, can also do simple mathematics using integers and float. Floats as you know are decimal numbers (1.5, 3.0, etc). While integers are the whole numbers. When doing mathematics, Python follows PEDMAS (Parentheses, exponents, division, multiplication, addition, subtraction) rules and depending on the function, you will either get an integer or float.

One of the most important operations in Python is the print() functions.

the print function in action
  • Note that in Python 3, it is important to put your variable in parenthesis, which was not need in the Python 2 version.

The print function will output the product of the variable that you tell it to. One of the best parts about this function is that you can input multiples variables or create a sentence by coagulating each string or integer that you need to. An example of this will be below, where I talk about dictionaries.

With the basics done, I move onto Lists, functions, and loops. This is where the fun begins — and this is where I feel like I can make cohesive programming outputs.

b) Lists, Dictionaries, and Tuples

Example of a List

Now for the good stuff.

First, I learned about creating and manipulating lists. This is a great way to create a sequence, arrange numbers or strings in a way that you can manipulate it, reverse, splice, and append it (there are many more operations). All the elements in a list will have an index, and one list can contain both strings and integers.

One of my weirdly favourite things that I learnt was creating and using dictionaries. A great way to specify indices, you specify a key to a value in this format: dictionaries = {‘key’: ‘value’}. As you can see below, the dictionaries made are a great way to construct sentences, keep track of each value, and great way to combine two variables together.

Using Dictionaries
Using Tuples

Finally, tuples are similar to lists, although — they are immutable, meaning, unlike lists — they cannot be amended, or sliced. One of the cool things about tuples is that with you can assign a variable to a string tuple. When using the print() function (as seen in the example), if the string is a word, each element in the word will be separated in a similar way of a list.

c) Creating a Function

One of the most important concepts in python is creating functions. Functions are a great way to conduct operations. Most functions, such as .mean, gcd(), etc. are in built into python (although you first need to import various libraries into python). However, sometimes in a code you may need to repeat a particular code multiple times, which may not already be in python, in this case — creating a function comes in handy. As seen in the example below, a function starts with defining the function and it’s variables with def myfunction (a,b,), provide an example, and finally, tell the function what to return. Below, you can find an example of how to create a simple function, and one that is a bit more complicated. Also, you can see how a function works and it’s output.

Creating a Function

In Conclusion

I hope this short and simple tutorial helped anyone that may need a simple start to Python, and using the most basic elements of Python. The reason for writing this article was not only helping any other beginners (such as myself) out there, but this was a great way to keep my memory sharp on different functions. One of the biggest struggles I have with coding is remember all the different notations and operations, thus, I’m hoping different posts such as this one will help me remember things better in my own personal mind dictionary (okay that was a bad joke).

If you took the time to read this! Thank you, and I hope it helped anyone starting out with Python! Stay tuned for more :)

--

--

Manali Shinde
One Datum At A Time

A health informatician and aspiring health data analyst. I am a photographer, writer, dancer, and public health advocate. Join me on my journey!