Transcription
Hello! During this lesson, we will install all the necessary programs for comfortable coding in future video lessons.
But first, I would like to recommend the website itprager.com. On this site, you will find code, homework assignments, and a lot of other useful information. The link to this lesson on the site will be in the description of this video. Check it out; you won't regret it!
To write code in Python, we first need to download Python itself and install it on our computer. For this, we can go to their official website; I will leave the link in the description of this video.
Here, we go to the Downloads tab, where we can download the latest available version of Python. If your version differs, that's okay, as regardless of the version, all the code we will write will work correctly.
So, let's download the latest available version. The installation process is very simple. If we are talking about macOS or Linux, all you need to do is click on the file and follow the instructions. After that, everything will be installed, and you will be able to work with Python on your computer.
For Windows, the process is similar, but on the first screen, you will also need to check the box for "Add Python to PATH." This way, you will add Python to the global environment variables, and later, through the terminal or command prompt, you will be able to call it simply by typing "python," and everything will work correctly.
Next, we need a program for writing code. In fact, you can use any program for coding; you can even use the standard Notepad. However, using Notepad will be quite inconvenient since it won't provide any syntax highlighting. Therefore, I suggest using more professional development environments.
For example, you can download a simple program like Atom; it’s very user-friendly. You can also download Visual Studio. Personally, in this course, I will be using a program called PyCharm. This is a full-fledged IDE, meaning it’s a complete development environment where I will write all the code.
In this program, there is also a built-in terminal through which I will run all my future programs. You can also download this program; it is available for free, and there is a paid version, but the free version will be sufficient for us. I will leave the link to this program in the description of this video. Download and install it on your computer.
You can also use any other programs, like Visual Studio; everything will work just the same, just with a slightly different interface.
Next, I suggest we create a new project. So, we open the code editor and click on "New Project."
Next, we need to choose a specific template. I want to create a simple empty project, so I select the "Pure Python" template. However, in the future, you can create your projects based on some templates, for example, you can create a project where Django is already connected, or a project with Flask or other frameworks.
At the moment, I am not interested in that, so I will create a regular empty project. I will choose the first setting and give my project a different name. The name can be anything; I will name it "IT Prager."
I also need to select a setting to indicate that this project will have a virtual environment. What is that? I will explain a bit later. For now, let's just indicate that there will indeed be a virtual environment.
I also need to specify the interpreter; in other words, I need to indicate the version of Python that we downloaded and installed on the computer. It is usually set by default, but if it is not selected by default, click on the three dots and find the folder where you installed Python. After you find that folder, click "OK," and the interpreter will be correctly specified.
Additionally, I do not want a file named "main.py" to be created automatically when the project is created, so I will disable that setting.
Now, let's click "Create" to create this empty project.
After creating the new project, we can immediately notice that there is a folder named "venv" in our project. This folder is the virtual environment folder, and it contains various libraries and frameworks needed for the correct operation of our project.
At the moment, I do not have any additional libraries, so all that is in the "lib" folder is just one additional folder that contains the Python interpreter. Thanks to this interpreter, we will be able to write code and later execute it to get some results.
Again, if you delete this folder, we will not be able to execute anything within this project; it simply will not be processed correctly. In the future, when you work with additional frameworks or libraries, all these frameworks will be installed in the project, and they will all be stored in the "venv" folder.
We will not need to work with this folder; it is for settings and should just be in your project to store all necessary dependencies.
Instead, let's create a new file, and in this file, we will write all the code in the future. To create a file, we can right-click on our folder, click "New File," and then we need to name the file. The name can be anything; I will just name it "main."
Next, we need to give it an extension; it should be ".py." This way, we indicate that this file will contain code in Python. If we specify, for example, ".txt," we will not be able to execute it as a Python file. So, the extension must be ".py," but the file name can be anything. I will just name it "main.py" and press Enter.
Now this file will be created. In this file, let's not write much for now. All I suggest is to output a simple word to the terminal, or in other words, to the console of our project.
To do this, we need to use the function called "print." We will work with this function more in the next lesson, but for now, let's just write it.
We call this function and put double quotes around it, where we can write anything. For example, let's write "Hello, IT Prager."
Now, I would like to execute this piece of code. How can we do that? We can either use the terminal or click "Run" here, but right now that option is not available, so let's use the terminal instead.
We go to the corresponding tab, and the terminal opens. The terminal is standard here; you can type all standard commands. For example, I will often use a command called "clear." This command is not related to Python but specifically to the terminal. With this command, we can simply clear the terminal.
I typed it, pressed Enter, and now my terminal is cleared. Quite a handy command!
Now, let's specifically call Python and execute this file. To do this, we type "python" followed by the file name. In my case, it is "main.py." If you named your file differently, specify the different name here.
I will just type "python main.py," press Enter, and now this file has executed. The result of executing this file is simply outputting some information to the terminal. Everything I wrote is in the print method, and this print method outputs the information that was in it to the terminal. Everything was processed without any problems.
Now, let's also set up the configuration so that in the future, we can just click this button, and everything will be processed correctly.
To do this, we need to click on "Add Configuration," then click the plus sign, and here we just need to add an additional configuration. We will name the configuration "Python."
Here, we need to specify the interpreter, which, as you can see, is automatically filled in, so I do not need to write it again.
Let's just name it "Python," and we also need to specify the script name, which is the main script that will be executed. To do this, I can click on this folder and simply select the script in the file selection format.
I select the necessary script, click "OK," and now you can see that the configuration is set up and named "Python." If I now click "Run," the code in this file will execute each time. Quite convenient!
In the future, I will just click this button, and it will do exactly the same thing.
If you find it inconvenient to click this button, you can always run everything through the terminal using the command "python," meaning you type "python" followed by the file name to execute the file you need.
I will just click the button in the future, and it will happen exactly the same way.
Well, this concludes our lesson. During this lesson, we installed everything necessary for comfortable coding in Python in the future.
In the next lesson, we will start writing various code and thus learn this programming language.
That's all from me. I hope you enjoyed the lesson! If so, don't forget to subscribe to the channel and join our social media. All the links are in the description of this video.
That's all from me. See you soon! Bye!