Table of Contents
Have you ever wanted to learn new programming language? What about Python? This is a language that is easy to learn and universal. You can use it almost everywhere. It is also very popular language in machine learning. Will you give it a chance? Great! This mini series will help you learn all you need.
A few questions
Learning multiple languages at once?
How proficient are you in you in the programming language you already know? Think about a simple scale from one to five. One is a complete beginner, three is advanced and five is master. How would you evaluate your skills on this scale? If you think are somewhere between one and three, it might not be the right time to learn a new language.
When you are a beginner to programming trying to learn a programming language, it is better to stick to that language until you reach advanced level. In this case, you could easily get into a situation where knowledge from your first language will start to mix with material from the second language you are trying to learn. The result is often confusion, slower learning rate and problem to use any of the languages you are trying to learn.
I know this because I tried it. It cost me a lot of time. Don’t do the same mistake. An exception is when you surpass this level in at least one language. If you are already proficient in at least one programming language your current knowledge is more resilient. Meaning, it will not mix together with new material. What’s more, your current knowledge can even help you learn new language.
If this is true, then, yes, go ahead and try to learn two or even more programming languages simultaneously. Otherwise, work on your first language and add Python on your to do list. Just remember that you are not wasting your time by focusing on your first language. As I mentioned, a solid knowledge of one language will help you learn another one. So, have patience.
Should I learn another programming language?
I think that learning another language is a good thing. When you know only one programming language you are limited by the constraints of that language. Every programming language has specific benefits, best practices, paradigms and quirks. When you know only one language you are thinking in a specific way, a way that is unique to that language.
This is not bad because it helps you use that programming language better and solve problems more efficiently. However, it still limits your creativity. Who says that this or that way is the best way to solve this particular problem? When you know more than one programming language, you can look at the problem from different perspective. This, in turn, can help you find a better solution.
When you think about it from this perspective, learning another language can help you explore new possibilities. It can introduce you to a whole new world and show you how much there is still to discover. It is like when Alice decided to take the risk and enter the rabbit hole. You can do the same. Enter the rabbit hole and learn a new programming language, such as Python.
And, if you are afraid that multiple programming will create a mess in your head, don’t be. Programming languages are just like spoken languages. When you learn one language really well, you can add another and then smoothly switch between them without experiencing any problems. The key is to learn the first programming language very well before you attempt to learn second.
Now, let’s answer the original question. Why should you learn specifically Python? There are at least four reasons for choosing Python as one of the programming languages to learn. First, it is beginner-friendly. Python is very easy to learn even for people with no prior experience in programming. This is why Python is often recommended as the first language to learn.
So, if you already know one programming language, or even more, learning Python should be very easy for you. The second reason is that Python is one of these languages able to sustain growth and popularity over many years. Python appeared in 1990. Not only it is not dying, rather the opposite. According to Tiobe index it is regularly one of the most popular programming languages.
In other words, Python is nothing new under the sun. It is a language with a very long history and a large amount programmers loves it and uses it. It is safe to say that you don’t have to worry it will suddenly disappear any time soon. The third reason is that it is a good language for web development. Python is often a preferred choice for back-end programming.
This is thanks to its simplicity, popularity, scalability, amount of resources that are available and number of good frameworks such as django. Finally, the fourth reason. Python is one of the most popular languages for machine learning and data science. This makes it even better choice if you are curious about any of these topics. It is also another reason why Python is here to stay.
Learning new programming language always takes some time, even if it is very easy one. And, as we discussed, it is better to use that time deliberately and focus solely on that one language, instead of trying to tackle more at once. So, take your time, think about these four reasons and decide for yourself. If you are willing to enter this rabbit hole, let’s get our hands on Python.
// or multi-line comment
/**/. In Python, there is just one choice. When we want to write a comment, or comment out some code, the comment has to start with hash (
Side note: There are people saying that Python actually has multi-line comments. They are wrong. What they are talking about is using
""". Unfortunately, there is really no such a thing as multi-line comment in Python. This is only a small “workaround” using multi-line strings as comments. This workaround takes the advantage of garbage collection.
Those triple quotes are treated as regular strings. The exception is that they can span multiple lines. And, since these strings are not assigned to a variable they will be immediately garbage collected when the code executes. Put simply, they will be removed. However, they are not ignored by the interpreter in the same way real comments (
""" This is NOT a real multi-line comment in Python. """ def mythBuster(): """ And neither is this a real multi-line comment in Python. """ # This is the only real comment.
const. The difference is in scope and mutability. In Python, this is easier. There is only one way or “type” to declare a variable. This also means two things. First, in Python you can change any variable you declared.
The second thing is that there is just one scope and that is block. Every variable you declare exists inside the block where you declare it. It is, therefore, accessible only inside that block. If you try to access some variable declared inside a function for example from the outside, the result will be an error.
Functions … or blocks
The answer is by using space, or rather indentation to more specific. When we create a block with some code we have to use
def keyword and indent the code inside. This also means one thing. When you write code in Python, you have to be careful about how you indent it. One extra space here or there will result in errors or the code will not even execute. So, watch the space at the beginning of lines.
A quick recap. Remember these four things. First, there are no curly brackets. Second, functions are called blocks. Third, create a block by using
def keyword followed by brackets (
()), with our without the parameter, followed by colon (
:). Fourth, indent the code that is supposed to be inside the block for one level. And, make sure to keep the indentation consistent.
Next, let’s take a look at
if/else statements. Just a quick side note. In Python,
if/else statement is also called “block”. It looks very similar to
Second, there are no brackets (
()) around the condition. Third, the condition is followed by colon (
:). Finally, there is no
else if. Python uses
elif. What about the
else? That is the same, with a very small exception of additional colon (
:). And, the same also applies to
When it comes to
if/else statements, or blocks.
The last thing we will take a look at today will be
for loops. When it comes to
for...in rather than the good old
Congratulations! You’ve just finished the first part of this mini series. Today, we took a look at and discussed the absolute basics. In the beginning, we started by talking about the topic of learning another programming language and why Python is a very good choice. Then, we explored topics such as comments, variables, functions or blocks,
This is just the beginning, only the basic. However, it will give you a good place to start. So, take the examples we used today and play with them. Try to run them, customize them and run them again to see what happens. This will help you get the grasp of the syntax and memorize it faster. The best way to learn Python is by writing code in Python. In the end, the best way to learn anything is by doing.
If you liked this article, then please consider subscribing.