YTread Logo
YTread Logo

PyCharm Tutorial | Full Course in 2 Hours

Feb 22, 2022
whats going on guys assalamualaikum welcome to friend code in this

course

i will teach you the best idea you should use as a python developer. back end development web development connecting to databases integrating with git

pycharm

has everything you need in this

course

i will make sure you know this ide inside out and you will see that by knowing the ins and outs of this ide you will become a much better developer better. I think if you are serious about becoming a better engineer then you should know your idea inside out for this course. I literally have a surprise for you so just give me a minute or so and I'll give you something really cool if you're new to friend code go ahead and subscribe give me a thumbs up so I can keep shooting these videos too if you don't you are part of the buddy code community go ahead and check out the private facebook group like us ll like this code where we are there helping each other and learning from each other how to code and i would love to have you there without further ado let's start this course off right so this course what i want you to do is try and practice while i teach i don't want you to just watch the video and not learn from me i really want to add value and make sure that by the end of this course you will be a better python developer by knowing how to use your ide inside literally practice as i teach also if you haven't joined the private facebook group as well as Discord please join because if you have any questions you can ask and n the group and people are ready to help you literally people are ready to help you and I would love to have you there too so you can share your knowledge with others this is it for now let's start this course the first thing we need to do to use python is install it on our machine so navigate to python.org and on this page right here c See we have the downloads link so go ahead and click downloads and right here because I'm on a Mac I can see the download link for Mac OS, but if you're on Windows, just click Windows or Linux. just use this specific version for your OS which is also great here you can see these are the active versions so the active version right now the latest is 3.8 here and if I show you 2.7 has arrived at end of life so you really shouldn't be using this version here and if I scroll down you can see we can make it aware of specific release versions but usually just go ahead and download the latest version you have support until 2024. so here you can see the latest version as i speak is 3.8.5 you can check this video later and if you haven't then if there is a new version all that i'm going to teach you in this course it will work with the version you will install it so let me go ahead and just download python there we go let's finish now let me open the downloads folder and here you can see I have python so let me just click on it and let me collapse this so that the installation process for both windows and mac os is really easy you just have to hit continue and then ok and then install so before you hit or put my password if you are on windows make sure you check the box that says add python to the correct path that's really important so you can use python from your terminal so on the mac it does it for me so here let me put my install password i just give it a second and voila so we've installed python success

full

y next let's go ahead and install a program that will allow us to write python code when it comes to python there are two text editors that are the most popular so you have vs code which is awesome but there is a jetbrains product called

pycharm

and this is by far the best idea for python d Developers so go ahead and install pycharm because its awesome and i always recommend jetbrains product because l The integration they give you is amazing so what pycharm really does for you is like a text editor but with a bunch of features that allow you to be more productive so with code vs you really need to install a bunch of plugins to get the best out of it but with pycharm it's all ready to go so let's go ahead and download pycharm and here you can see the version for let me just zoom this in so you can see a version for both Mac Linux and Windows as well than go ahead and download the version for your operating system and you can also see that there are two versions so you have a pro version that comes with additional features for the web. development including html, javascript and sql support but most of the time the community edition is more than enough so go ahead and download the community edition it's free and you don't have to pay anything so i'm j only I'm going to allow it just give it a second ok that's done let me open the downloads folder and right here you can see we have pastel charm community so let's go ahead and double click on that and then here the process installation is very simple so just drag and drop this into apps and there we go now let me just search for pycharm and then open it right here just say don't import settings if this is your first time installing pycharm and then right here, so if you've never used pycharm go ahead and stick with these key bindings you can also choose the actual ui theme so if you want light or dark I'm going to go with dark and what i'm going to do is just skip the rest and set the defaults and there we go we success

full

y install pycharm next let's go ahead and write our first python program as you saw we have two versions when it comes to pycharm we have the community, as well as professional and professional. it gives and ou extra features when it comes to eg web development or connecting to databases eg so it's actually the ide you'll need so you don't need anything else but for charm so I recommend than try pycharm and you might be thinking ok pycharm is actually a paid version but don't worry i have a code you can use and try pycharm for four months free just use the friends code when you try it and this was the surprise. i wanted to give you this is all for now let's keep creating our first program let's go ahead and create a new project and right here you can give it a name as well as the actual location where the project is stored for my example i'm just going to name this as my and then python and then app and then you look here where it says base interpreter you can see we have python 3.8 so this is the version we just downloaded so if I click this dropdown to see all the differences. ent versions of python i have but let's go ahead and stick with the last one and basically what an interpreter is is a program that runs your python code which is literally what it is and then here you'll see we have this checkbox create a main dot py welcome script basically if it pastes and grab it because i want to show you everything from scratch go ahead and grab the box if it's checked and then just build everything ok so now we have pycharm open so this is the main screen here you can see a Lots of controls, but don't worry because I'm going to show you exactly what each thing means, so you can check out a page like this or you can watch right here, um, actually, you know, teaching us how to use pycharm. you can see search everywhere type shift twice to bring up the project view command go to the file and you can see basically these are some of the keyboard shortcuts and to be fair you see you know the power of the keyboard shortcuts within pycharm but what I want to show you is in the lower bottom corner here you have this square so this is a button so what I'm going to do is click on it and you can see everything is gone, so in case you don't If you don't see all those tabs right click on it and then all these tabs will appear and right here remember we installed python 3.8 just so you can see the actual version here so python 3.8 and then the name of our application.
pycharm tutorial full course in 2 hours
So if I click on that you can see we have the interpreter so this is a program that runs our python program we can even add one we don't need to add one because we have the latest and if I want to access the interpreter settings , you can do it so I'm going to click on it and this takes me to the interpreter configuration with a bunch of packages here so these are the packages that make up the interpreter so this is all python packages we don't have none of this to worry about so let me cancel t you out of this and there you have it now that you've gotten this far next let's go ahead and create a very simple python application right now let's create a program that will print something to the console, so here you can see we have the project tab so you can click on it or what I'm going to do in this course is teach you a bunch of keyboard shortcuts and the reason why I always emphasize keyboard shortcuts because they make you a much better developer. more productive because it knows how to use the ide from the inside out instead of having to rely on, for example, if my mouse is here I need to go over here and then click on the project so here you see we can open the project to the right by pressing command and then one to the right and you'll see the equivalent for windows so I'm going to press command one and you can see it opened right here so now inside my python application here so this is the project we've created I'm going to expand it and then inside here right click and then new and then choose python and then file there we go so we have a couple of options here we have the python python file for the stub unit test but let's keep the python file so let's go ahead and type main and then enter there we go so this is our file so main.py and here we can write some code so I'll collapse this project tab to PO I can press here or I can press command then one just like this so keep remembering these keyboard shortcuts as I teach you throughout this course so let's create a very simple program so the program just prints to the console correctly so we'll just focus on learning the ide in this course if you want to learn more about python i have a whole course on python that teaches you everything you need to know about python so for now type print and this allows us to print to the console and then here i'm going to say pi and so the charm is oops and then awesome like this and now we have this program here that prints to the console so one thing to note is you can see we have the line numbers here , so line number one, if I press enter, you can see we have line number two, so we can keep track of the number of lines we have in each of our a files to run this program we have a couple of options a couple of options so the first time you run a program that doesn't contain a parent doesn't contain a parent So what I mean by that is right here let me order a x, I'm going to cut this out and then type main, just type main and you can see that pycharm is giving us an autocompletion and we're going to cover and we're going to cover everything related to autocompletion so here I'm going to hit enter and if you notice which what we have alright what we have is this play button right here so this play button just appeared so if I delete it line one so I'm going to press command and then forward slash to comment to the right so just p ut the pound sign you can see that disappears the play button disappears so what i had before was pycharm it's awesome so the two ways to run it is if you have the main so here the main right you saw this hat this um the play button comes up and we can run it so let's click on it and we have a couple of options we can run debug or build so what we want to do is just run and here you can see we have pycharm it's awesome now come on I'll come back for a second and what I want to show you is this so I'm going to comment on this and if you haven't noticed if you haven't noticed we have the play button right here , so this is the play button. right and i'm going to explain this in a second but now click on this dropdown and then edit settings and then python inside remove main we're going to remove that setting and then hit apply so now we don't have the play button here and how we run a program like this so we can right click and then we have the ability and to run main and there we go so now we can run the main file like so what this creates for us is a configuration of execution, which is this, so this is what you saw here, so this configuration ofrun is the settings we can use from now on to run the app properly so if you want to run the app just click run main here and it will just use the settings we have we haven't specified anything we haven't edited but we we have a setup so we can run it as many times as we want now another way you can run the program as well is by rerunning it so here you can see we've rerun and then main and if you look closely we have keyboard shortcuts as well to the right you can see the keyboard shortcut is control and then f5 if you want to run is shift and then f10 so you can run again and you can run so you saw three ways to run your pro oh actually four ways for you can rerun you can run by clicking the play button here when you have an r in the settings we can click the button right and then run main and if we have d let me delete this again so you can see it inside this setup basically we can add for example environment variables uh interpreter options running working directory so we can customize this quite nicely and we can even enable parallel runs so we're not going to mess up these values ​​so here I'm going to hit ok and oh actually what I wanted to do was remove the configuration so just let me remove and then apply ok and then you can see now the only way we can run is right click or we can open the run tab here on the right or if we have the main method like this and now we can run from here so there you have it we've created an application and now you know several ways to run python code with pycharm before proceeding with this course i want to do two things that will benefit you a lot so what i am going to do is go to pycharm here at the top and click preferences so you can see the keyboard shortcut with pycharm there is a keyboard shortcut for everything you can click preferences or I'm going to press command and then comma and there we go so this is the interpreter you saw earlier and here we can customize the settings properly so the first thing i want to do here is the following go to plugins and here you can see we have a list of plugins installed and then these are all plugins installed by default so you can see we have git github mercurial subversion copyright intelligence machine learning huh terminal so Basically these are things that come with pycharm so what I want to do is switch to Marketplace and here we can look for 3rd party plugins so here you can see we have material so this is the actual material topic so if if you want to experiment with this you can do it but i'll show you exactly in a second how to work with themes but what i want to do is install this plugin called preview and then the wizard and you. you can see the grades are here and actually the name is here on the right presentation wizard so what this plugin allows you to do is land the keyboard shortcuts and as it walks you through this course, you will be able to see the keyboard shortcuts that I am using. so go ahead and install there go and then apply and ok now if you are asked to restart pycharm do it to pick up the changes now lets see if we have it so we have it installed so what am i going to do here's the next thing.
pycharm tutorial full course in 2 hours

More Interesting Facts About,

pycharm tutorial full course in 2 hours...

I'm going to right click and then run and now check this at the bottom. You can see we've got the keyboard shortcut right so that's why I want to make sure you have the presentation wizard so it's really Awesome now let's go back to the preferences so with the charm preferences or the method command keyboard shortcut and then the comma and here let's look for the presentation. right here we can customize the display wizard we can say ok you can display for four seconds here we can even increase the font size so let me say something a little bigger let's say um 60 ok so you can see properly and come on change this to five seconds so you see the keyboard shortcuts on the right and then you can say right you can move it to the right to the bottom top and here on the right the main keymaps you can see here is mac os so mac os is the main key maps and I'm going to touch on key mapping in a second but for now leave it as it is and here alternate keymaps are whatever you want because I know many of you are using Mac OS or Windows correctly and because I'm on a mac i want to show the alternatives also for windows users here and then apply and then ok let's go back to that page in a second for the key maps now s i right click again and then run you can see the keyboard shortcuts below and it will take you five seconds nds and now you can learn about keyboard shortcuts so make sure you install the presentation wizard because it will teach you how to use the keyboard shortcuts over time and when you realize you'll be flying around using pycharm the second thing I wanted to do is to change the key bindings so the key bindings are something you have to decide which key bindings you prefer, so go to settings so command then comma or pycharm here and then preferences so actually preferences so here you see we have keymaps so click on that and my choice key mapping is intellij idea classic so this is what i'm looking for so i've been using intellij so intellij is another idea that's mostly for java development and if you want to learn about intellij i also have a course full on how to use intellij idea but i've been using intellij for quite some time and this is what i prefer ok so this is what i'm used to and this is what i'm most comfortable with because i know every key shortcut on the board if comes from for example sublime text you can choose sublime or emacs you can also choose emacs you can also install additional keymaps to follow this course I suggest you use the same keymaps as me and you will see that this is one of the best so usually me and my colleagues have long discussions about what is the best keymap and to be honest its just a pro its just a personal preference but to follow this course go for the intellij idea classic and then apply if you have to go back now to the layout wizard remember the layout wizard in the layout wizard appearance and behavior here key maps is intellij idea classic so this is the one i'm using so if i apply and then ok now here if i press command and then w and this selects a word you can see the selection on the right so via command w i'm going to press command w again and you can see the keyboard shortcut for intellij idea classic as w Well as for windows this is something you needed to set because it's important that you follow the exact same keymaps if you want to change keymaps there is a shortcut and that's control then tilde so you can see uh right there really control and then I think it's um it's like the backslash but that's where the tilde is so control and then tilde for me and you can see there the keyboard shortcut and then go to keymap and then you can change it like this so you can say if you want mac os for example or emacs but the one we chose was this one here so if I change to mac os now we have mac os so let me go back to change it like this ue I'm going to use the keyboard shortcut to control and then tilt for myself and right here I'm going to press 3 so we can use keyboard 3 and then I want 3 again which is the classic intellij idea and there we are wow that's right how to set up your keymaps with pycharm when new to an idea The first thing you might want to do is customize things so we installed the layout wizard, set up the key bindings and now let's learn how to change the theme so that the color theme have things available and it really all comes down to personal. choice so let's open settings so I'll hit command then comma or just go to pycharm and then preferences I don't know why I keep saying settings but it's actually preferences so here we go now appearance and behavior right here , if i zoom in on this and its look so here the right look or here is the same look you can see we have the theme here so the theme and we have a couple of themes here so we have dracula light intellij light high contrast , etc. we also have d so here the source so this is the general source for your ide it's not the actual text that you write your code within and I'll show you that in a second but this is for the general idea so here for example if I go for example if I change this from 48 to 22 for example I just want to see that this will be small but I want 42 because I want to see it clear so 42 here and here let me change this to intellij light and then i apply and you can see now everything is white and to be honest the light theme doesn't look so bad but the reason why I don't use it is because if you sit in front of the screen for many

hours

your eyes will get tired as well which i usually just use the dracula here and then oh let me show you the eye contrast first apply it and you can see this looks really cool too and mac os lite whats the difference there yeah this is just the mac os theme but i usually just go with dracula so here it applies so this is the actual theme right now we also have the color scheme so it's not within the appearance but it's inside the editor and then color and then scheme so here we have more than one option actually so we have a bunch of options here so let's try monokay monokai which is very popular apply and then ok and you can see now this is the actual quality this is the actual color theme and it's completely different so you may prefer this one because it's got a lot of contrast but if I come back let's try a different one so Twilight this one is good too , you can see I actually really like this one to be honest and let me go back there too and let me show you one more and usually you'll end up playing around with all these color themes applied and this one isn't bad actually but to be fair, everyone is nice, so let me come back here and what I'm going to do is just stay with dracula so I'm going to apply the default theme and if I go back and open the plugins here if I write inside the marketplace make sure you're inside the marketplace type theme like so and you can see we have a bunch of themes here so stuff ui dark one this is from ato I think Dracula and many others are right this is how more themes are installed in python.
pycharm tutorial full course in 2 hours
Now I'm going to hit ok and one tip is if you want to quickly change themes press ctrl then tilde where is the tilde key or the tilde and now look at this we can edit the color scheme so if I hit enter you can see we can choose between the right ones so if I want Monika I just press six and there we go if I go back so control and then check and here the subject too so I can press and now I can switch to the right so this is just a quick tip so here it even gives you the preview so sure mac os light dracula high contrast so i'll leave the dracula and then press ctrl tilde or backtick one more time and let's go to the schematic color one more time and here you can if you want github i don't think i showed you this but this is actually all white so it will change everything so if you press yes you can see this is the github color scheme and actually It's pretty good, I'm not going to lie and one thing I like i would love to know is what color theme do you prefer so let me know if you are a guy or girl with a dark or light color scheme so if i reverse then i will go with dark for now so dracula and then yes and there you go , this is how you change the overall theme with pycharm so if you want to increase the font size you can use your mouse so here I am going to zoom in using my trackpad and you can see I am zooming things in correctly so this is it too big or can i make it smaller and this is the largest font size i have i have set so if you want to make it even smaller than this go to preferences so command and comma then here the good thing is that we can look up the font and you can see we have the font size here so in the editor and then the font here so you can change the actual font. you can switch between these available but I usually stick with the default one it's more than enough and t So the size here so if I go for example to 14 or instead we go to 16 here because I think that's the one that accept and you can see now it's smaller so this is the 16 um it's actually a lot smaller because now I can make it smaller but if I go back here and change it to 24 for example and you can see here like so that right at the bottom right here you can see the actual size that it looks like because I have a big monitor I need something big and because I wantyou can see the keyboard shortcuts for windows if i want to delete i press command then y c command and to delete a line i can press application error then delete and there you go if you want to undo the changes command z and you can see it just undoes the line there we go command z then command y to delete and command d to duplicate and if i want to cut the line properly then if you want to cut this line so i can paste it somewhere else i can select it like this and then command y then x so it cuts the line but you saw we had to select it first on the right so here what I'm going to do is press so I'm going to press command then w and I'll go over this this is actually select word so I'm going to press command then w again and you can see that it's just extending the selection command w command w command w and you can see that it just keeps expanding expanding expanding and if I want to reduce the command shift w and then if i want to delete that i can just delete or if i want to delete the whole line or if i want to cut the whole line right i will select the whole command then x so you can see the power of knowing these keyboard shortcuts y if you need help click menu then edit and you can find everything we've done here but I'm just teaching you the keyboard shortcuts along the way so you can benefit from it let's say here so let's select um all in double quotes so command w command w and there you have it if I say for example let's say we have ahmed right ah we meet so this is a name if I want to put all caps I want to select that so command and then w and then command shift then u for upper and check this ok so it's just toggle in case of command shift then u lowercase if i want to put all lowercase here i can press command shift u lowercase all command shift u again and you can see now everything is in uppercase so let me undo that and right here let me just uppercase a shift u command and there we have it now a Cold one What I want to show you here is let's say here you want to have a right space you want have a space between line five and line four so that you can type or you can type anything correctly so let's say you're here and you basically want to do this you want to go here and then enter and then go here and then type you saw that that took me a while alright I'm going to hit command then z and what I'm going to do is hit command option and then enter and you can see this is much faster look at the keyboard shortcut so let me do it again so even if i'm here command option then enter and now i can type something here ok so this is great now again command switch command option and then enter and you can see it's just l to line above if you want the below line press the command shift to the right so instead of the option is the command shift and then you have it right and this is really cool because now you can see that you don't i have to use because i don't have to use the arrows and then press enter to add a space to add a space or actually a new line so here i can just use the keyboard shortcuts on the right lets say um we say print to the right and let's say we don't have this line here so we're here and we say ah and then med to the right and you can see that we're missing, we're missing the trailing parenthesis, so what we can do is hit the same command so into an option and then enter to complete the statement and then move to the next line check this command shift command shift enter and it didn't actually move to the next one so I need to press it again and there you go let's say you want to indent this file ivo so here you can see it's not formatted right so to format this file you can press option command and then l and you can see everything is formatted and apart from the last line so I want this like this actually if I have another one here, for example, you can see that that moves it here and here, so if I don't have, um, a newline. you can see this is actually saying no newline at the end of file a and it's saying reformat the file so that's exactly what i've been doing right so if i press the command and then and then the l option formats the file and we're ready to do the same thing if you have some spaces in here I think if there are no spaces because that's part of the string but I think so so I meant outside here so this is wrong of course, i mean you can definitely do it but it's wrong but if you want to format everything and maybe have a space here you have another space there and basically this is not correct so if you want to format things just press command option and then l and format three lines if you want to reorder so if you want to reorder for example line six with line five you can press shift and then option and then you can reorder like this you can see I'm moving it up it's just I'm using the error and you can see the keyboard shortcut below and I move it down, up, down just like that search inside of pycharm so what we're going to do is open the project tab and right here open the my python app folder and for now let's create a file and you'll see I can use my mouse there or I can hit ctrl enter and then the python file so I'm just using the keyboard I'm just using my keyboard so python file and lets say you have utils here and let's have another file so here write math and you can name them um whatever you want so i forgot to select the python file there you have it now let's learn how to search so if you want to search you have two options you can search literally everywhere pressing shift twice so shift one shift twice and actually you'll see i typed shift twice but was too slow so i need to be a little bit faster there we go this brings up this slash search here so for you you won't see it full screen because my font size is maxed out so for you it will be smaller but you can see now I can search for literally anything so if I were to say plz example print you can see it's your search ng all so here I can say for example let me press shift again twice there we go so if I search for example git you can see it's searching for literally anything and that's why i was telling you there's a better way to search and this is like you're literally searching everything now you can narrow down your searches for example if you just want classes you can see we have classes here we have files symbols and actions for each of these. if i highlight all you can see it's a double shift class it's command n files command shift n or shift command n symbols and then actions so you can see the keyboard shortcuts for all those right so if i want to narrow so if hit the command and you'll see now it's just looking for classes so if for example now I delete um git right let's say I want to look for a class called math like so and you can see we found a class called math and this is with in our file on the right so let's go to our project I'm really sorry so if I delete it and we try to find something that starts with s and look we have um python sanitizers text to speech controllers you might not even see this uh but it depends on what you have so scan from json scan there go right this is how you search for the file so you saw we had math we also had utilities this is how we search so if you want b Find files, change the command to n right and files is pretty much the same in python, because technically it's a file, but usually, for example, if I had created a new file, here I'm going to say, say, for example, students.json so this is a json file and here we're going to be empty so you don't complain now I can hit shift then n to browse files and then student and there you go we're not going to cover um symbols and actions like this what actions um basically do you remember you saw we could move one statement to the right so it's an action that you can technically look up right here and remember I showed you the keyboard shortcut but you have a lot of actions here so let's say you know you want delete for example and there you have it you can see how to delete a line how to delete a word and basically these are all correct actions and you can search for whatever action is available to you so here you search in everywhere to make it an action and the good thing is you. get the right shortcuts and there you go it's actions in action so if I say for example scratch card if I want to create a scratch card then this is like a file I can use just to play I can do that using the keyboard shortcut or just use the action so if I hit enter here you can see we can create different language scratch cards so python regex xml yamo etc there you go you saw the function of search it's super powerful and go ahead and practice to be very confident searching with pycharm let's learn another way to search with pytram so open the Students.json file and here what I want to do is for example name a key name and then let's say ali and then comma let's say ali has cars and this will be an array and for now let's say bmw and then a tesla we're going to take this object so slice it and this will be an array and I'm going to press option command and then l to bleed and can den see it works with literally anything and here i'm going to press comma oh actually let me take this and then comma here and then paste that there will be maria and then maria has an audi and that's ok she just has a car so so now let's learn how to search so basically we have you know some text we want to search huh if i open main dot pyth p and you can see we have some text so you saw it earlier we can search by pressing shift n or shift command n or double shift y if i search let's say maria this is not text search it's just the search function for classes, files, symbols and actions so here you can see we have all and all searches for everything but what we want is search. for this word inside our ide so let me escape this so I'll hit cape and search to the right so let me show you so here I can say search I can type find and basically this is what we want so find um we have the search section so let's go edit go edit then search and you can see just press command then f and this will search so if I press shift f or actually just command f my bad uh if I search for ahmed you can see what you are looking for ahmed um if I search is you can see what we found is if I search for a we have several a and then we have the arrows here so we can find the previous occurrence more or less because this is too big and it doesn't allow me to find the next correct occurrence. ch is the error next to here that I can't select so you should see it and basically you can search up or down to the right but the limitation of searching this way is that you're only searching within this file so if you want to search everywhere to the right I'm going to hit shift ctrl then f to the right so you can see the keyboard shortcut below but now look at this if you want to search for maria you can see that you're looking anywhere literally in anywhere and here we go search for tesla you can see we found tesla and it's here and if I search it's you can see by charm it's amazing basically now we're searching the whole project so this is a much better way to search you can search in the module directory of the project and basically you can narrow it down now here too let's say we want to search correctly so we want to search for a file skin so I can say now I just want to b search for anything that ends in json and there you have it so we found our file so let me go ahead and show it to you again so within edit we have found and you can even replace it too so lets say i want to replace hello with another thing.
pycharm tutorial full course in 2 hours
I'm going to hit the f command and then find and here you can see that you can basically search through a lot of things you can also deselect the occurrence and you can even find in the path and find the path is what I just showed you you can search literally anywhere we have too. find uses so this is really cool so if I select find uses we don't have anything but here let's say we have def and then we add so this takes x and y so it's a function that takes x and y and then returns x and then more and then and so if I format this like this and then go back to the main screen so I just hit ctrl then tab so that takes me back to the previous file so now you learned something new so here what i'm going to do is say add and import i can import right here math.ad and then if sa print and then pass 2 and 2 let me run it so you see the output so here is 4 right but now if i go to math dot py and then if i select this method name go to edit find use and you can see the shortcut ofif I select it you'll see that open files recent changes files current file and so on but let me just leave it as it is and then we can preview if we want before we refactor or we can just refactor so another trick here is if I press the option you can see we have these highlights here so r and then p which means I can just press with my keyboard r and then that will trigger the refactor if I press p which will trigger the preview so let me do the preview first so p it tells me you know there's a problem and basically i think there's something heavy when it comes to renaming huh files with pycharm but let me cancel that so i'll cancel that and let me give you another example here so if you want to rename from ahmed press shift f6 then lets say name and you see it updated everywhere the same here so lets say we want to update that name here i can p press shift f6 and then let's say add and then numbers and then I can press command and then r right because I don't want to use the mouse and you'll see where we go with pycharm so it allows us to be so productive just using these little tricks so the option and then r and you can see it shows me the uses and I'm going to say just refactor and I think it still doesn't like it so it actually refracts ted added numbers here so let's check in math.py yeah it works but I don't know why, um, it was complaining, but here, for example, you can see that the function name must be in lowercase. here let's say underscore and then numbers and then refactor here and then refactor and if we go back to main.py there you have it ok one last thing I want to show you when it comes to refactoring is how we replace things so it learned search and replace like so which again if i want to search let's say the word ahmed or the word hello so i'm going to hit the f command and then search for hello and you can see we found a occurrence if we want to replace just hit the r command and we can say replace hello with hello and then world or maybe some spanish hello and here you can see we can replace and we can also replace all so if we have more than one occurrence we can replace all at once so let me show you if i do update this and then hit command then f and then r and now we have two occurrences that I can replace one by one or replace all so let's replace all and you can see that it's done if I go back so I can replace r one by one for here replace one so this line 14 gets replaced and then replace again and then zero results that's awesome so we can also look at how we've done it here if I press ctrl shift so you can see that we can find in the path so hi but now if i press ctrl shift r it's the same thing we can replace so let's replace back to yellow or maybe ciao this time so some italian there and if you remember correctly replace the path replaces literally everywhere so let me just show you here if I go to, say, student.json here and let's say we have maria and then hello so here I'm looking inside this file but I'm going to search um all parts which is shift ctrl f uh find the right path and if you forgot go edit then search find path so this is what i'm doing right and you can see here replacing path too so i'm going to find rar in the path first and you can even replace at the same time and now we actually just replace at the same time so edit then find the replacement path we want to replace ola with ciao and you can see we find both in students json and inside the main right so it's everywhere now we can go and actually i can't see it because my font size is too big but you should see a button there that says a button says replace right so let me see if i can hit option then r no that doesn't work here oh actually enter so enter it just works so i just hit enter and it's just doing one by one but you should see a button that does the replace for all instead of one by one enter and there you have it so if now i escape this and check this ciao and if i open students.json we have maria ciao it's not a name let me delete that and there you have it. find and replace when it comes to refactoring so i've been stressing a lot why you should be learning the keyboard shortcuts so remember for every action we've done so far if you want to find the keyboard shortcut you can use search, so here if I press shift twice you can see we have this lookup right and what I'm interested in is the actions so to access the actions you can press the shift command and then a so let me escape from this and then the switch command and then a and so so here I can say for example the extract method so you can.
I've seen this or maybe variable so variable introduced variable here so that's when you extract with variable too and a bunch of good stuff so really keyboard shortcuts are something you have to learn and you know they come with time and just watching you I'm not going to learn it right away because you need to know how to practice and basically it comes with time, so what I'm saying is anytime you want to do something right, anytime you want to do something, try to find the keyboard shortcut. for that is the way you are going to learn it so pycharm is very powerful and by learning the keyboard shortcuts you will fly with this ide it is so powerful so you can also see here and onwards you can see here give your suggestions are correct they tell you ok so you should know to rename your variables so you should do things this way or not for example in this alex method you can see I have these yellow lines so if I put my mouse there.
I can see that the function name needs to be ok in lowercase so you can see that I can say ok give me more actions so I'm going to hit here in my case option and then enter or you can or you can ignore things like this but what I'm going to do is hit command and then enter and then here you can see I can say okay I'm going to rename the element and this will be alex underscore and then method and then if I hit option and then here you can see it's highlighted r and I can press r and then refactor r and now it's renamed everywhere so be aware of that and what you can do right is your right mouse your mouse you'll see here I'm using my mouse now technically I could avoid using the mouse Also, if you want to go. this is how to go pro but for example if i want to access this tab right here then the project tab and navigate if i want to do that how do i do that? and then rewrite something, so here I am.
I'm going to hit command and then one to take me to the project tab now I'm just going to use the up or down arrows and then the application right arrow if I want to go back to the editor just hit escape and I see that I'm here and if I want to close command 1 I open like this so let's say we want to open person.py and if I want to rewrite I just hit escape and look at this and there are even plugins that are just meant for this purpose so here there is a shortcut so if i go to actions here and then look for a line so i want to see it line oh actually i think it's go to line so go to the right line so sort and then g so now you see there ok i didn't remember the actual shortcut but now i know you know if i want to go to a line number i just press command then g so what i'm going to do here is for example let's say i was in the project tab , so here I was browsing and then I press um, i nenter so now let me hit enter here and then go back so hit enter and if I want to go back I just hit escape now if I want to go back to line one I could use the up and up and down arrows or I can hit the g command and now I can go to line one there we go to the g command again go to line seven for example and you can see the column also on the right if you want so here let's say column seven and you can see that I am here and this is awesome so you can just use your keyboard if you want but this is more advanced. level, but as you start to learn um pycharm, I recommend that you start using these keyboard shortcuts and tricks that you've been learning throughout this course, so I just want to emphasize the power of keyboard shortcuts and pycharm is here to help you remember that you're here to help you be more productive now let's learn how to create a simple test with pycharm so that when you write code you should really be testing its functionality so there's no point in you writing code and then just hope it works. you need to make sure and ensure that what you build works for different edge cases so with part of the charm creating tests for your code is very simple lets say we have a file here so let's have a python file and we're going to call this like gender and then underscore converter enter and here let's have a function and if you want to learn more about all this you can check out my course where I teach on functions and stuff but for now let's just have a simple function here and then let's say convert and then underscore and then sort here we're going to take sort and we're going to say sort is equal to and then sort dot and here you see we don't have any method on this and this is because pycharm doesn't know the type of this parameter here so let's say this is a str so just like str and now I can say dot and you can see I can say and then superior so let's put this in uppercase first and then we're going to say if and then gender is equal l and then we're going to return mail and then elif and then I want to grab this and I want to say if gender equals f so f so and I'm missing a column there and here too I'm going to say female and then we're going to return unknown and then underline the sort and I'm missing a column there and let me format this command option and then l and there we go so here you see we have this method let me make it smaller so here we have a method and we want to test it is it okay to create a test just to make sure that you know it does what we want so to create a test for this function here we can open the project here and then we can right click and then say new python file and then we can say python unit test so this it's a way now remember we're all keyboard shortcuts so if I run away from this and we try to use it let me just collapse that and let's use actions so here I'm going to say unit and then try and see if we have a lgo here so try so no keyboard shortcuts or actually here go try so here's the command and then shift t to the right go try so let's try that so command shift t so i can see that says i want to go to test but there isn't one and it gives me the option to create a test so let's create a test and it gives you the name of the file here so test and then the genre and then the test class name will be test and then the test function here is the sort of the test converter so that's what we want test and if I press ok now check this so it actually generated the test for us so if we were to manually create the test we would have to say so now we need to import the test case unit test and then write a class test passes the test case and then you get the gist right like so which is why the keyboard shortcuts you know are simple mind awesome so now we have a code generator for us so if i come back here then to this py gender converter and let me hit the t shift command again and now you can see i have the test so i can navigate to it now or I can create a new test if I wanted to but I want to navigate to it and this is our test class and if you open the project tab you can see here so this is the uh oh it's not actually here so this is the actual file it generated for us next let's go ahead and write a test to test that our code works right now than having our test class generated let's write some tests to make sure the gender converts to the method works so here if you've noticed we have these play buttons so let's play these tests so basically it's just a way to run our tests so run them and here we can e see the test failed so you can see that on the right you can see that you ran a test for 0.003 seconds and then it failed so here actually let me expand this you can see this is a test so this is the test gender converter this is the class and then the test class which is this and then inside we have test gender converter and it was a failure so the reason it failed is because we have here so you can see it says self.fail so what we want is to pass so we want to make this test pass so if I remove it from there let's see if we can run it like this so it can run all the tests inside this class or just onetest so just run it and no good tests were found so what we're going to do here is this we're going to say eigenpoint and then assert is equal to a d here so we have to pass the first and second arguments, so here let's say we have so the first argument is hello oh actually let's say m and then the second is mail like so let's run the test again and this fails ok let's see why and I'm just showing you some unit tests here so here you say you see the assertion failed and this is because it says the expected so we were expecting um m to equal masculine right? but it's not equal, that's what it says here, so now if I change this to m and then run it, hooray, you can see that we have green, so a test passed successfully, so what we want to do is use our method so we want to say convert underline the genre and right here you'll see we've got these red lines so import from here or press option and then enter import now here we're going to pause we're going to pass m so let's pass m to the right and this gives and then this gives us a sort so what we're going to do here is let's g to say actually so this is the actual result and let's hope equal to and then send a mail so now I'm going to say right so I'm going I'm going to have the real here and I'm going to pass the expected so let me move this down here so if I run this and see what happened but we have some red errors here and what is it saying then it's actually saying this is deprecated , so I say same and it says use assert equal instead of fair enough come on use a sir equal and then rerun and check this now everything passed fine and no errors so this is a test so here we expect the output to be male and we know our method works so let's say test gender converter and then when I'm male let's take all of this put it here let's say when I'm female and I just want to say you know this is probably more advanced but I'm just showing you the test functionality inside pycharm so here if we pass let's say we pass ok i just want to show you first t we're going to pass if you can see it failed and this is because here we are expecting a female but we have correct male so let's change this to female because we know we want female here we go and we can even change this to lowercase because our um function does uppercase to the right so here if I run it you can see it works and finally te, let's take it all back so let's paste everything and then when it's unknown and here let's say hello like this and then what We had in our function here an unknown gender so let me just grab this and then pause here so this is as expected and let me run you can see it works fine so this is the individual test so you can see we have so here we have three tests so let's run all of those and I can expand this and actually let me say show past and here we go so you can see we have three tests and some description as well as test when female, when male and when unknown so this is just a college intro I'm testing with python and pycharm and you can see the functionality of writing tests so it's really cool so here you can see the information how many failed how many passed um the execution time and a bunch of other cool stuff so I'm not waiting you know how to test and if you are a bit confused just let me know i can give you some resources on learning how to test and testing is something you will need to know at some point this is it for now grab me the next one when it starts your career as a software engineer and you write python code you need to learn how to use any version control like git so github will allow you to store your code in a remote repository where you can work alone or with a lot of people you are right so if you work for a company this is most likely what most companies will use or maybe another version control like bitbucket and there are many others but github is one of the most famous so it is very important if you know how to use git and github so if I go back apycharm here go to the menu so here remember we looked at vcs so basically here we can work with any version control so lets say you want habi litar version control integration for this project right here so my python app so you can click on it and then you'll see you can select the actual version control so what we want is git so you'll use git to 100 unless you're working on some legacy projects but most of the time it will be ok so you can say it's ok now let me cancel from this first i want to show you something so here if i go to vcs , you can see we have vcs popup operations so that's a keyboard shortcut so let me go ahead and hit ctrl and then v and there we go to the right so here I have all the options so enable version control , create a git repository, etc. you can see everything turned red everything ing turned red and this is because we now have these checks here so we can update the project that we can commit and we can push to learn git is out of scope for this project but just i want to show you that you have the flexibility to commit and push the code correctly so if i hit ctrl then v again you can see the options are now completely different and this is because we enabled version control so here you can see that we can commit we can create a file that we can move back we can push we can hide and hide and so on to create a file we can press command k the keyboard shortcut is right there so let me hit enter and check this out so you can see that we can fetch some files so if i put this figure so we can fetch files here let's say we want to add these files here po rque everything below vn is not

hours

but all of these are hours and also an idea so this is a pie chart so this is not ours so we want to add that so we want to add to vcs here and then i can cancel so now if i open the project tab you can see this is green because we've added to vcs and i don't expect you to know all this but i just want to show you the integration is here so now what I can do is push this to a remote branch so if I hit ctrl and then v right now here we can push the changes but first what we need to do is commit so let's go commit this so I just hit the commit button commit there or if I run away from that and you can see we can hit command zero to the right or I can hit command k and it's the same thing so here for example I could say mi and then project and then first commit then commit let's compromise this v We're going to commit that and we've got two to-dos to remember and we can review them or we can just commit as is we're going to commit and there we go so all that's been committed and you can see it's not green anymore so here you can see we have another tab here for what it is to get one and if I open that you can see nelson committed five minutes ago and basically these were the correct changes so this is all we've committed and you can see the actual message here my project first. commit so if I collapse out of this and you can also see the branch here on the right you can see the branch which is master and also here we have the branch so this is the local branch and you can create new branches so here let's say we want to create a new branch called function and then script x create and now we've switched to a new branch so here you can see we now have two local branches and one last thing I want to show you is if now we go let's say we have a new method , so let's double this and then let's say subtract and then let's change plus 2 minus like this and let me format and now you can see line 4 through line 7 this is green and this says these are new changes we've made and you can see the f the file is blue right math.py so if you want you can revert the changes so the line is gone um let me put it back or if we want now we can say right now let's add this so this It's my change, let's say now what what We're going to commit this is a function and to subtract numbers here we go we can commit and if I close this now you can see it's no longer green because we've committed and if I press ctrl v we can push the changes so here we have to define remote and add the url you get from the repository you create once you're up and running with github or any other version control, so I'll leave it here because I don't want to take us out of the scope of this course, which is mostly about pycharm, but know that the functionality to work with git and any other version control is really very good.
The idea of ​​pycharm is to give you everything you need. you need to write and build software without leaving your ide and i think you have done a very good job with pycharm including all your other ide okie dokie wow you have managed to complete this course and i am very happy for you so hopefully now you can see the power of pycharm and know that you don't expect you to remember everything we've covered because these things come up when you use more and more and practice and practice and practice so what I want to say is you should try using the keyboard. shortcuts if you want to do something then maybe try using the correct actions you have learned about actions use actions just to find out what the keyboard shortcut is and then start using keyboard shortcuts also make sure you have the presentation wizard because that way you will remember the keyboard shortcuts much faster and at some point you won't need them anymore, so I have used it before and I recommend you also use it if you want to learn more about python or are interested in python courses.
Go ahead and check out my website where I have a selection of python courses ready for you that's all for now I had fun teaching you this awesome ide and I'll meet you next time

If you have any copyright issue, please Contact