1.1 Your first Python Code | Python Full course 2024 #learnpythonin2024 #mlwithakansha

In this tutorial, Akansha Yadav walks beginners through the initial setup for Python programming using Visual Studio Code (VS Code). She demonstrates how to create a project folder on the desktop, open it in VS Code, and add both a standard Python script (.py) and a Jupyter Notebook (.ipynb) file. Akansha explains the functional differences between a plain Python file and a notebook, emphasizing that notebooks are better suited for data‑science, analytics, and machine‑learning work because they allow code, markdown, and results to be organized in cells. She shows how to select the appropriate Python kernel, run code in a notebook using Shift + Enter, and execute a script via the Run Python File button, including a brief troubleshooting of a kernel‑related error caused by duplicate filenames. The video ends with a congratulatory note encouraging viewers to replicate the steps on their own machines.
Chapters
In today's video, I will show you how you have to start your programming. So you have already set up everything for Python programming. Throughout this course, I will be using Visual Studio Code, but in case you wanted to use PyCharm or any other platform, then you are free to use it. So how to work on this Visual Studio Code is you have to just launch it in any mode if you wanted to. And then I would prefer you to make a folder. So what you can do is you can just move on to your desktop, right-click on it, then tap on New, then Folder. Once you have the new folder, suppose I'm writing Python Pose Labs This is my folder's name. So you have to just open the same folder in the Visual Studio Code. You have to tap on File section, then Open Folder. Then it will take on to— take you onto this system, onto your own system. You have to search for the folder and then you have to select that folder. Once you have selected the folder itself will open in Visual Studio Code. After opening your folder, you have to create files. So our next step is to create file. What you can do is you can move your cursor over here, you will get the option to create new file under the folder itself using this icon. Else you can use this new file option as well. Else you have another third option, which is click on File, then click on New File. Suppose I'm using this one, you have to tap on this and then you have to write your file name. Suppose it's my first file, so I will say first.py. .py is for Python. In this course, you will find most of the files with the extension called .ipynd, which says Python notebook. There is a difference between normal Python file and Python notebook, which is— which we also say, which we also call as the Jupyter Notebook. So you can choose as per your convenience, but I would prefer you to use Jupyter Notebook because in machine learning, in data science, data analytics, when you are going to work with the datasets and all, you will need Jupyter Notebooks. And in companies also, they prefer you to work on notebooks. So here is my file which I have, like, I have given the name. Then you have to press Enter. Once you will press Enter, the file itself will open. So here I have created a Jupyter Notebook file. Same way I can create first.py, which is going to be my Python file. So there would be two files. One is my Jupyter Notebook, another one is my normal file. So normal file looks like this. Normal file looks like this, an empty area with a line number 1. In case of this, there will be cell means this is code cell. There can be a markdown cell, code cell, markdown cell, and so on. You can see over here Python, markdown, Python, markdown. But in case of normal Python file, there would be nothing. There would be just an empty file. Why I am preferring you to use Jupyter Notebook is because here in this Jupyter Notebook, your code will be arranged in a manner So which will be easy for you to understand later on. If you are going to review your code, it will be easy for you to go through it. All the labs in this course you will find as a Jupyter Notebook. You just have to download it and you have to launch that particular lab in the Visual Studio Code itself. So let's write our first program. So I'm just going to write a simple line in both the environments. So let's say I wanted to welcome you all onto this course. So welcome to— I just wanted to print it. So once you will open the folder, you will set up everything. So every time when you are going to work, maybe it will ask you and sometimes it may not. You just have to go on to this and you have to select the kernel. Kernel is nothing but the Visual Studio Code is basically when you wanted to work on different, different languages, you can use Visual Studio Code. Like you wanted to work on HTML, CSS, Java, JavaScript, or any other language, then Visual Studio Code allows you to use that. So that is why there is an option to select a kernel on this Visual Studio Code environment. So right now I'm going to work with a Python environment because this is my Python file. Either it is a Jupyter Notebook or it is the normal Python file, you have to select Python kernel. Once you have selected the kernel, you can run the command. If you are using Jupyter Notebook, it means this ipynb file, then you can use a shortcut called Shift+Enter to run your command. Once you will press Shift plus Enter, your code will run and another cell will be created for you to write down the code. So here you can easily see that you have another option also to run the code. You can use this Run button to execute it, and this Run All will run all the cells which you have created in this. So I'm going to write down, take the same code and paste it in this Python file. So here you are not going to use Shift Enter because there is kernel along with the terminal. You can use it, but entire file will run for you. So if you can see over here, once I have pressed Shift+Enter, it just took me onto this terminal section. So what you can do is you have to use this Run button. Click on this Run, Run Python File. It's taking some unknown error. Let us run this again. Okay, so there are similar file names. Let me rename it to name it as rename. Let me run it. Yeah, it worked fine for us now. So there can be some glitches because I was trying to run on the same kernel. There was another file which was in process, that is why we were getting that unexpected error. But now it is working fine for us. So that is how you have to create your files. You have to write down your code and you have to run it. So congratulations, you have written your first code and you have successfully run that. Don't forget to do the same on your system.










