There are tons of programming languages out there today, and Python is one of the most popular. The reason for its success is its relative simplicity (at least compared to C ++). In this article, you will learn how to start learning the Python programming language and what difficulties you may have to face.
Without my book, most people spend too long trying to learn C# the hard way. This book is the only one that will get you to learn C# fast without wasting so much time. It includes one chapter that painlessly teach you the necessary skills to master C# and to create your first apps.
Step 0. Download and install Python, development environments
In general, this step can be done in almost any of the first stages of learning Python. In fact, when you’re just learning syntax and reading literature, you don’t need Python itself or a development environment. But some people want to prepare in advance. Perhaps there is some logic in this. Therefore, download Python itself on your PC or laptop and choose some kind of development environment (if you have a Mac, you do not need to download the programming language, since it is already preinstalled there, but Windows owners were not lucky in this regard).
What is a development environment? In simple words, this is a text editor in which you will write your code. There are a lot of such development environments. Here are just some of the programs:
- Visual Studio. It is a feature rich IDE compatible with Mac OS and Windows operating systems. Offered as a free and paid subscription. The program has its own set of extensions and offers the possibility of development using various programming languages. To work with Python, you need Python Tools for Visual Studio. If you are using Linux, there is no VS version for this OS
- Visual Studio Code.It is a full featured code editor for Windows, Mac OS and LINUX. To add Python, you need to find it in the Marketplace and then install it.
- Sublime Text.This is another code editor that can be used to work with Python. It offers not only support for editing Python code, but also a whole set of plugins with which you can significantly simplify the set of code and expand the editing capabilities.
- Eclipse + PyDev.This IDE contains many addons and extensions for development in different programming languages. For Python, PyDev was created, with which the user gains access to the Python console and the ability to debug code.
Step 1. Learning the syntax
Why do you need to know Python syntax? First of all, so that in the future you can give commands to the computer to perform certain actions. Here’s the simplest example – you want to get the value of the expression 2 + 2. How to do it?
If you just ask the computer to do a calculation like “Please, tell me how much 2 + 3 is,” nothing happens. The computer just won’t understand you. In order for it to perform such calculations, you need to refer to it using a special syntax.
Here’s an example of how you can calculate this amount using Python:
At first glance, it looks outlandish. But you need to get used to it. With the help of various commands, you will give the computer tasks that it will perform. Of course, this code is the simplest one. There will be a lot more code in the process of writing programs. But for now this is enough for an example.
In addition to syntax, you need to understand functional and object-oriented programming.
Where can I learn Python syntax? You can start with various tutorials, of which there are quite a few on the Internet. For example,one of them. This tutorial is good because it gives a good base. In addition, the presentation of the material is just the same as for a beginner developer.
There is also such textbook, but it is, in our opinion, a little more difficult to understand. Here’s another pretty interesting one tutorial for beginners… Here, the syntax, like other aspects of working with the language, is described quite simply.
In addition to tutorials and tutorials, you can also watch various videos, which are full on YouTube. At first, you will not be able to determine their quality and usefulness, but as you get to know the language, you will add a few authors to your bookmarks, and forget about others completely. Read the comments before watching the video. Sometimes the developers unsubscribe there and give their assessment of the quality of the material.
Step 2. Decide on the direction
Python is a multitasking language that can be used, for example, to do web development, write games, or do artificial intelligence. A lot will depend on what choice you make at this stage. For example, the choice of libraries to study.
Yes, you heard right. Learning the syntax of the language and starting to program in it today is only half the battle. In any modern programming language there are several (and sometimes several dozen) useful libraries that are used to perform certain tasks.
This step is completely theoretical. You just need to make a choice in favor of what is closer to you. At the stage of learning the syntax, there is not much difference in what you will do in the future.
Step 3. Solving problems
This stage is very important, as it helps to consolidate knowledge of the syntax of the Python language, as well as to get a practical understanding of programming. As you learn the language, you will see many code examples. But until you create many functions with your own hands, develop many algorithms that will perform some interesting tasks, you will not learn anything.
Where to solve Python problems? The question is quite simple. You can arm yourself with the almighty Google and ask him directly: “Where to solve problems in Python”? But we decided to help you with this and have prepared some interesting links.
First, you can solve problems yourself, having a console and development environment at hand. But this approach does not work well, since you will not be able to test yourself comprehensively. Therefore, it is better to use online sites specialized in this kind of tasks:
- https://codingbat.com/… You can find Python and Java tasks here. There are both simple and fairly complex tasks. True, so far there are not so many of them. By the way, there is also its own help section, where you can update your knowledge on some aspects of Python programming.
- https://www.practicepython.org/… This site provides many Python programming problems with solutions. The site is entirely in English, so you need to be at least intermediate in this language.
- https://edabit.com/… A universal site with tasks for different programming languages. The web resource is made very cool, you can set your skill level and gradually move from the basics to the top. The tasks are compiled by the site users themselves. And in each category there are a lot of them. The site has a verification system. Points are awarded to users. There are both Russian and English versions.
Basically, these three resources are enough for you for now. For example, on Edabit, tasks are constantly updated, so if you start learning syntax today, by the time you move on to tasks, their number will please you.
Step 4. Libraries
So we have come to that happy moment when you can already write your own program and now you need to choose a set of libraries with which you will work.
For those who work with artificial intelligence, the following set of libraries is offered:
For quantum computing, libraries such as:
That’s all. It would seem that your path to junior is over. But do not rush to close this article. Below are some helpful tips to help you learn the language.
Guideline 1. OOP
Learn Object Oriented Programming. This will allow you to become professional. And it’s very easy to use it in Python. By the way, OOP is a programming paradigm, in which the basic concepts are the concepts of objects and classes.
Recommendation 2. Use functions
A programming language is beautiful when the code is beautifully written in it. The function helps to make the code simpler and more readable. Moreover, with its help you will reduce the amount of code in your application, which is also a big plus.
Why are functions needed in Python programming? Just imagine that you have a piece of code with two variables that need to be added. As in our example above, where we talked about the syntax.
If you have only one piece of code with this equation in your program, don’t worry. It’s better to learn the best programming practices right away, though. But what if the same piece of code is planned to be repeated several times in the application?
Without using the function, you will be doing regular copy-paste. All this is not very good to look in the code, since you will constantly repeat the same piece of code with different values of the variables. The function allows you to once wrap this piece of code in such a way that if you need to use the same formula with the same variables another time in the code, you just call this function and give it the required parameters.
Complicated? Not at all. Perhaps the first functions will puzzle you, but later, when you create your first application, you will understand how much they make the programmer’s life easier and make the code more beautiful and practical.
Recommendation 3. Leave comments
Programmer programmer strife. Unfortunately, not everyone who is engaged in development today is able to leave such comments that would be really useful. And some even manage to write a bunch of code without comments.
It would seem, why are they needed? When you write one function with only one action and two variables, comments are unnecessary. Everything is clear here. But if you are writing a large application with long code, of course it is better to leave comments. Even for myself, in order to understand later which part of the code is responsible for what.
What else are comments for? Imagine that you are offered good money in another company. You packed up and left, and another developer came to your place in the old company. Naturally, he gets your code and is perplexed. Without comment, he will delve into the essence of what you have written for a very long time.
It would seem, well, okay, but what if such a code comes to you? In general, immediately learn mutual respect and comment correctly. Anyway, try to initially learn the so-called Best Practices, that is, best practices in programming.
Recommendation 4. Don’t know yourself, ask Google
Many novice programmers who are just learning the basics of development in Python or in another language are somehow embarrassed to contact Google, and sometimes they do not know how to ask questions correctly.
In fact, Google (conventionally any search engine) is a programmer’s best friend. If you think that all developers remember and know everything, you are deeply mistaken. Of course, they don’t go to Google to see how the language declares variables or how to wrap code in a function. But they have enough other questions.
In addition, there are a lot of specialized forums and sites where you can chat with other developers and get answers to your questions.
It is very important to learn how to ask correctly. In this case, you will receive the most useful answers in a short time. Although at first you will have to learn how to use a search engine.
In this article, we’ve walked through everything you need to get started learning Python step by step. We’ve also given you some practical tips, which are really helpful as they come from your programming experience.
C Programming Language introduces you to the most commonly used programming language, one that has been the basis for many other versions over the years. It is a great book, not just for beginning programmers, but also for computer users who would want to have an idea what is happening behind the scenes as they work with various computer programs.