APPRENDRE LE PYTHON #1 ? LES BASES & PREREQUIS

2.71M views1739 WordsCopy TextShare
Graven - Développement
Aujourd'hui , on se retrouve pour le 1er épisode de cette nouvelle série sur l’apprentissage du lang...
Video Transcript:
Hey well hi to all this is Graven for this first episode on Python language learning in this new series, we will see step by step how to create programs with this language through different notions that will be specific to this universe that is computer programming If this is your first experience in this field I recommend beforehand to have seen this video which is an introduction to the world of programming So . . First of all we could ask ourselves the question .
. Python? But what is it ?
It is a computer programming language as there are many others having seen its first release in the early 90s thanks to its creator Guido van Rossum who made other projects including a "Gry" web browser that was released in 1999 But here you will tell me, why THIS language, and not another? and well Python has the distinction of being both very simple to learn so perfect to start, very powerful, it is widely used in the scientific world, for numerical calculations for example and finally, it has a fairly large community base with which you can interact and exchange when needed If for example, you have a problem Well. .
! Now that we have understood the stakes of this language, I propose to download together the different prerequisites necessary to develop Python in good conditions. We will need .
. Two components First, we will need what we call, an Interpreter or Environment It's just a place where our python code will run because by default you can not do it like that on your computer, anywhere To download this environment, you just have to go to the Python site which will be in description, in the category: DOWNLOADS and here you will have the different version, for Windows, Linux, MacOS and the others For my part, I'm on Windows so I'll click here, you can at this level, choose the appropriate version for your operating system for me, I'm on Windows 64bits So here I'm going to take the installer as an executable The download was done very fast because it's only 25MB You can now proceed with the installation so you will click on it This is a classic installation, so no difficulty at this level Here! After a few seconds, the installation was done well, so we can close this tab Then we will need what we call an IDE, it is an environment of integrated development, a software on which you will be able to write your code We could very well use a simple text editor just to do python, like Notepad ++, SublimText or even the notepad But if you want to start on a good foundation, take something of a higher quality For my part, I'm going to use this IDE called PyCharm which was created by the company JetBrains which made quite a development environment for developers, precisely So you go here, press DOWNLOAD NOW, you can at this level there, choose the version of your operating system and among two versions, first of all, you have a version of PyCharm for professionals It pays, but here you have a free trial, and a second version Community that for once, is totally free and free, so we will focus on this second version to start developing, so you press DOWNLOAD and it will download Okay!
Once the download is finished, we will launch the installer and we will proceed to the installation, so you press Next, here you can choose the destination file, we will stay on the hard drive C We do next, I'll check here the 64bits launcher that will create a shortcut on my desktop, and I will create associations in . PY and quite simply, the extension, PYTHON script We do next and we proceed to the installation There you go! The installation is finished We can see that on our desktop, an icon was added with just a shortcut to launch the PyCharm software So we will directly check this option and finish to launch by default, it asks us if we want to import preferences, since this is our first installation, we can put here No, we do ok Then we can choose from the two themes that are proposed by default Intellij theme that is white or Drcula theme that is black, I will rather lean towards a black theme, otherwise a white IDE may tire your eyes Especially if you develop at a late hour, you can press SKIP and PyCharm launches Well!
we will be able to start to create a first project on which we will be able to work throughout this series, you will press Create New Project and here we will have to give him a name, I will call him for example myfirstproject at this level, we can open this option and here we will have to choose the environment in which our Python code will run, by default, we have to create a new environment with what is by default "VirtualeNV" and "Conda" we will not dwell on it, we we will use ours Moreover, which will have been found at this level then Python. exe is the file that will allow to execute Python code precisely So you just have to go to this directory If you are on Windows to go to the local file it's very simple, you press Windows + R and you will write the following command:% appdata% done OK, you can go here in AppData, Local and in Programs and here we will have Python, Python 37 and here I have my executable, python. exe, you just go here, copy the address, go back here, choose Existing interpreter, browse, we make browse too, and here we will be able to paste this address So that's going to directly redirect you to the right file and we can open it, and here select our python.
exe, we do ok and we do OK, perfect! You can now do here, CREATE Here we are now on our development environment to our left we will have all the files that will compose the project that we want to create While on our right, this is where we will write our code simply, we will start by creating a first Python script, for this you will do right click on the document myfirstproject, you will then make a new Python File and we will be able to give it a name for example we will call it test It's a Python file, and we can do OK here, on our left we can see that a new file has been added, while on our right we will be able to start writing our code, what I propose to do today is a very simple program, which will simply write: Hello World in the console when we are going to launch it, in general it is what we do when we discover a new language, we must first, a condition that checks when triggers the launch of your program, for that, you will simply write here MAIN and make ENTER So, what comes from this generation is what is called a condition, what does it do? Well when we will launch our python project He will go directly in this condition to say: This is the beginning of the program, so here we can put a first code for example, to send a message in the console, we will use a function called: PRINT if you do ENTER, it will automatically generate it This is called: Self completion Then you go here write open double quotation marks to write text inside for example, I will write here Hello world like this, Now, to launch this program, you will press the little green arrow at this level then RUN test and look in the console, we have Hello world Now what I just did is not totally right!
Why ? because we should rather create a main function that does just all the instructions that must be done! when the program turns on So we could very well, at the top, here, create a function thanks to the little keyword def which will be called main and which will be the first function that will execute when the program turns on, so I'm going to open the parentheses here, and when we talk about the function function we'll come back to this notion, do not worry!
So to start my function, and put code inside, we'll put here, at this level, we can put our famous print ("Hello world") and to say that it is the end of the function it will be enough simply to have two line breaks here If you put 3, you will have an error because it will not know where the code should stop, so that's part of the python synthesis Now, when our program will start, instead of putting this famous PRINT, or could very well call this function hand like this, it surely makes you an error on it, you just have to do ALT + ENTER and ignore this error, so if now I restart my program, you will see that I still have Hello world. We can change by putting Hello Graven, and the result is still operational, note that we can put several instructions one below the other because our code is executed line by line, for example here I can write print ("Hey, hello to all! "), look at that level, I still have an error, since I put that a single line break!
consequently, he does not know if I have finished or not to write my code so we have to add a second one, if now I launch the program We can see that I have the two messages that are displayed So here is! For our first project! In the next video we will see how to create variables that will temporarily store values, make some calculations, .
. . So here is a little what I wanted to show you today, in any case I hope that this new series will please you, if it is the case do not hesitate to the Liker, Comment and share it, to subscribe to chain to follow, the next videos, Anyway, it was Graven, ciao everyone and see you next time!
Copyright © 2025. Made with ♥ in London by YTScribe.com