In this Python tutorial you will learn everything you need to get started with Python programming.
Python is the world’s fastest growing and most popular programming language, not just amongst software developers, but also amongst mathematicians, data analysts, scientists, accountants, network engineers and even kids. In fact, it’s the ideal programming language to learn first.
In this tutorial, you will learn the following:
Click the Quick Navigation/Table of contents button to go directly to any of the sub-topics listed above
Python is a multi-purpose programming language which you can use for a wide range of jobs; such as data analysis, artificial intelligence (AI), machine learning, deep learning, Robotics, writing automation script, building websites, mobile and desktop applications as well as software testing or even hacking. So if you want a high-paying long-lasting career in any of these areas, especially AI and machine learning, Python is the programming language to put those opportunities at your fingertips.
According to indeed.com, the average salary of a Python developer in the US was over a hundred and fifteen thousand dollars in March 2018, and here are four more reasons that make Python the most desirable language.
Whatever you want to do, it is likely that someone else has done it before or has done something similar, because Python has been around for over 20 years.
Here are six reasons that makes Python so special:
With Python, you can solve complex problems in less time with fewer lines of code than many other programming languages. That’s why huge companies like Google, Spotify, Dropbox, Netflix, Instagram and Facebook have embraced this beautiful and Powerful language.
To demonstrate how concise a python code can be relative to other programming languages, let’s see the examples below
Let’s say we want to extract the first three characters of the text Hello World.
This is the code we would have to write in C# – str.Substring(0, 3)
This is how we would do this in JavaScript – str.substring(0, 3)
And here’s how we would do it in Python – str[0:3]
From the example above, we can conclude that Python has the capability to render codes relatively concise than many other programming languages.
There are two versions of Python namely:
In this tutorial, we’re going to Learn Python 3.
Now we are ready to download and install Python. The first thing you need to do is to head over to python.org. On this page, under the Downloads Menu (image below), you can see the latest version of python. Currently, The latest version is 3.8, chances are in the future when you’re reading this tutorial, there’s a newer version available. Don’t worry all the materials in this course will continue to apply with the future versions of python.
So go ahead and download the latest version of python and then run it.
If you’re on Windows, you’re going to see a checkbox saying “Add Python to PATH.” This is very important, make sure to tick it. Otherwise, you’re not going to be able to follow the tutorial. Note that Mac in Linux by default comes with an older version of Python that is Version 2. So now go ahead and click the “install Now” button then you wait for the process to complete.
So this environment you see here is what we call python interpreter, which is basically a program that executes python code. We can type our python code in a file and give it to the interpreter or we can type our code directly in the interactive shell.
In programming, an expression is a piece of code that produces a value, so we can write an expression like 2 + 2 and hit the enter key, we get 4.
when we add 2 + 2, we get a value, that is why we refer to this piece of code as an expression.
Let’s try a different kind of expression. Let’s see if 2 is greater than 1.
We get “True” which is an example of a Boolean value. You’re going to learn about these Boolean values in the next section.
Now, what if we type “2 > 5” then click the Enter key, we get false. So in programming we have True and False which are similar to yes and no in English.
Now what if we type 2 > and we don’t have a second value. Just press enter.
We have a syntax error. In programming, syntax means grammar, just like we have the concept of grammar in the languages that we speak, We have the exact same concept in programming. If we write a sentence that is not grammatically correct, chances are some people may not understand that sentence.
So in this example, we have this expression which is incomplete. It doesn’t have the right grammar or syntax. That is why python interpreter is complaining by returning an error.
So this interactive shell is a great way to quickly experiment with a bit of python code, but that’s not how we build real world applications to do that we need a code editor.
When it comes to typing Python code, you have two options. You can use a code editor or an IDE, which is short for integrated development environment.
An IDE is basically a code editor with some fancy features like Auto completion, which means as you type code this feature helps you complete your code, so you don’t have to type every character by heart. It’s a productivity boosting tool. It also gives you additional features like debugging, which means finding and fixing bugs in your programs, testing and so on.
For both code editors and IDEs, there’s so many options out there but the most popular code editors are VSCode, Atom and Sublime text. You can use the code editor that you prefer. In terms of the IDEs, again, there are so many options out there but the most popular one is PyCharm. In this tutorial, we shall use VSCode (Visual Studio Code).
Later in this tutorial, I will show you how to install a plug-in or an extension that would convert VSCode to a powerful IDE. So, before going any further, head over to code.visualstudio.com and download the latest version of the VSCode, follow the installation guide and install VScode on your computer.
I’m going to show you how to convert VSCode to a powerful IDE by using an extension called python, with this extension or plugin, we get a number of features such as
Don’t worry about memorizing any of these, as we go through this tutorial, you will learn the features.
Now in VSCode, on the left side. Click the extension icon by the left. This opens the extensions tab. So these are the extensions that we can install in VSCode to bring in additional functionality. you’ll see under the recommended tab, python extension. if you don’t see it, use the search bar at the top and search for Python.
Now go ahead and click the install button and then you will have to reload VSCode after python is successfully installed.
After VSCode is installed, you should see a message at the bottom right corner saying “linter pylint is not installed”. So, as I said before, linting is about finding potential errors in your python program. Code linter is a program or a tool that analyzes your code and finds its potential problems.
Now for python, there’s several linters out there and pylint is one of the most popular ones that this python extension uses by default. After installing the extension, we are good to go with jumping into python programming practice.
Note: Make sure you chose the right Python version which is Python 3.x at the bottom left corner.
When choosing a novel to read, many people consider not just the genre or author,… Read More
Many readers search for “What is Regretting You about?” before diving into Colleen Hoover’s emotionally… Read More
When readers ask “Is Regretting You worth reading?”, they are usually looking for more than… Read More
Colleen Hoover has a remarkable ability to craft emotionally resonant stories that linger long after… Read More
Colleen Hoover’s Regretting You is one of those novels that quietly pulls readers in and… Read More
HIS DOE, HIS DAMNATION by Viviene is an engaging, emotionally charged adult billionaire romance novel… Read More