PyCharm Tutorial | Full Course in 2 Hours

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
what's going on guys assalamualaikum welcome to amigos code in this course i'm going to teach you about the best ide that you should be using as a python developer pycharm is by far the best ide when it comes to python development whether you want to do back-end development web development connecting to databases integration with git pycharm has everything that you need in this course i'm going to make sure that you know this ide inside out and you'll see that by knowing the ins and outs of this ide you will become a much better developer i think that if you are serious about becoming a better engineer then you should know your ide inside out for this course i literally have a surprise for you so just give me a minute or so and i'm gonna give you something really cool if you're new to amigos code go ahead and subscribe give me a thumbs up so i can keep on recording these videos also if you're not part of the amigos code community go ahead and check both the private facebook group as well as this code where we are there helping each other and learning from each other how to code and i would love you to have you there without further ado let's kick off this course [Music] right for this course what i want you to do is to try and practice as i teach i don't want you just to watch the video and not learn from me i really want to add value and make sure that at the end of this course you are a better python developer by knowing how to use your ide inside out literally practice as i teach also if you haven't joined the private facebook group as well as discord join because if you have any questions then you can ask on the group and people are ready to help you literally people are ready to help you and also i would love to have you there so that you can share your knowledge with others this is all for now let's kick off this course the first thing that we need to do in order to use python is to install it in our machine so navigate to python.org and in this page right here you can see that we've got the downloads link so go ahead and click on downloads and right here because i'm on a mac i can see the download link for mac os but if you are on windows simply click on windows or linux you can simply use this the version specific for your operating system which is cool also right here you can see that these are the active releases so the active release right now so the latest one is 3.8 right here and if i show you so 2.7 has reached end of life so you shouldn't really be using this version right here and if i scroll down you can see that we can have you know specific release versions right but usually just go ahead and download the latest version which has support until 2024. so right here you can see that the latest version as i speak is 3.8.5 you might watch this video later and if you haven't if there is a new version everything that i'm going to teach you in this course will work with the version that you will install so let me go ahead and simply download python there we go let's finish now let me open up the downloads folder and in here you can see that i've got python so let me simply click on it and let me just collapse this so the installation process for both windows and mac os is really straightforward you just simply have to press continue and then agree and then install so before i actually press or actually put my password if you are on windows make sure to tick the box that says add python to the path right so that's really important so that you can use python from your terminal so on the mac it does it for me so right here let me put my password install just give you a second and there we go so we've successfully installed python 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 which are the most popular one so you've got vs code which is amazing but there is a product from jetbrains called pycharm and this is by far the best ide for python developers so go ahead and install pycharm because it's amazing and i always recommend jetbrains product because the integration that they give you it's amazing right so what pycharm really does for you it's like a text editor but with a bunch of features that allows you to be more productive so with vs code you actually need to install a bunch of plugins to get the best out of it but with pycharm everything is out of the box so let's go ahead and download pycharm and in here you can see the version for let me just zoom this so you can see a version for both or actually mac linux and windows so go ahead and download the one for your operating system and also you can see that there are two versions so you've got a professional which comes with extra features for web development including html javascript and sql support but for most of the time the community edition is more than enough so go ahead and download the community edition which is free and you don't have to pay anything so i'm just going to allow just give it a second all right so that's done let me open up the downloads folder and right here you can see that we have the pie charm community so let's go ahead and double click on that and then in here the installation process it's very simple so simply drag and drop this into applications and there we go now let me simply search for pycharm and then open it up open right here simply say do no import settings if this is the first time that you are installing pycharm and then right here so if you've never used pycharm go ahead and stick with these key mappings you can also choose the actual ui theme so if you want light or dark so i'm going to go with dark and what i'm going to do is simply skip remaining and set defaults and there we go we successfully installed pycharm next let's go ahead and write our very first python program right as you saw we have two versions when it comes to pycharm we've got the community as well as professional and professional gives you extra features when it comes for example to web development or connecting to databases for example right so it's actually the the the ide that you will need so you don't need anything else but by charm so i highly recommend you to try pycharm and you might be thinking right pycharm is actually a paid version but don't you worry i've got a code that you can use and try pycharm for four months for free just use the amigos code code when you try it out and this was the surprise that i wanted to give you this is all for now let's carry on to create our very 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 so for my example i'm going to simply name this as my and then python and then app and then you see right here where it says base interpreter you can see that we have python 3.8 so this is the version that we've just downloaded so if i click on this drop down you can see all the different versions of python that i have but let's go ahead and stick with the latest one and basically what an interpreter is it's a program that executes your python code that's literally what it is and then right here you see that we have this checkbox create a main dot py welcome script basically if it sticks and take it because i want to show you everything from scratch go ahead and take the box if it is ticked and then simply create all right so now we have pycharm open so this is the main screen right here you can see a bunch of controls but don't worry because i'm going to teach you exactly what everything means so you might see a page like this or you can see so right here um it's actually you know teaching us how to use pycharm you can see search everywhere double type the shift key to open the project view command one go to file and you can see basically these are some of the keyboard shortcuts and to be fair uh you will see you know the power of keyboard shortcuts within pycharm but what i want to show you is on the bottom lower corner right here you have this square right so this is a button so what i'm going to do is click on it and you can see that everything disappeared right so in case you don't see all of those tabs right just click on it and then all of these tabs will come up and right here remember that we installed python 3.8 right so you can see the actual version right here so python 3.8 and then the name of our app so if i click on that you can see that we have the interpreter so this is a program that executes our python program we can we can even add one we don't need to add one because we've got the latest one and if you want to access the interpreter settings you can do so so i'm going to click on it and this brings me into the interpreter settings with a bunch of packages right here so these are the packages that make up the interpreter right so all of this is python packages right we don't have to worry about none of this so let me cancel out of this and there you have it now that you've reached this far next let's go ahead and create a very simple python application right now let's create a program that will print to the console something so right here you can see that we have the project tab so you can click on it or so what i'm going to do from this course is actually teach you a bunch of keyboard shortcuts right and the reason why i always emphasize keyboard shortcuts because they make you a much better developer you become much more productive right because you know how to use the ide inside out instead of having to rely on for example if my mouse is here i need to go all the way here and then click on project so right here you see that we can open the project right by pressing command and then one right and you'll see the equivalent for windows so i'm going to press command one and you can see that it opened right here so now inside of my python app right here so this is the project that we have 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've got a couple of options here we've got python file python for unit testing stub but let's just keep python file so go ahead and type main and then enter there we go so this is our file so main.py and in here we can write some code so i'm going to collapse this project tab so i can press here or i can press command and then one just like that so keep on remembering these keyboard shortcuts as i teach you throughout this course so let's create a very simple program so the program will just print to the console right so we're just going to focus on learning the ide in this course if you want to learn more about python i've got a complete course on python teaching 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 then charm is oops is and then awesome just like that and now we have this program right here that prints to the console so one thing to bear in mind is you can see that we have the line numbers right here so line number one if i press enter you can see that we have line number two so we can keep track of the number of lines that we have in each of our files so to run this program we have couple of options couple options so the very first time that you run a program that doesn't contain a main right doesn't contain a main so what i mean by that is so right here let me just command an x i'm going to cut this and then type main just type main and you can see that pycharm is giving us some auto completion and we're going to cover about and we're going to cover everything about auto completion so here i'm going to press enter and if you notice if you notice what we have right what we have is this play button right here so this play button just appeared so if i remove line one so i'm going to press command and then forward slash to comment right so i just put the pound sign you can see that that goes away the play button goes away so what i had before was pycharm is awesome right so the two ways to run it is if you have the main so here the main right you saw that this hat this um play button comes up and we can run it so let's just click on it and we have a couple options we can run debug or create so what we want to do is just run and here you can see that we have pycharm is awesome now let me go back for a second and what i want you to show you is this so i'm going to comment 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 drop down and then edit configurations and then python inside delete main we're going to remove that configuration and then press apply okay so now we don't have the play button here and how do we run a program just like this so we can just right click and then we have the ability to run main and there we go so now we can run the main file just like this so what this creates for us is a run configuration which is this so this is what you saw here right so this run configuration is the configuration that we can use from now on to run the application right so if you want to run the application you just click on run main here and it's just going to use the configuration that we have right we haven't specified any things we haven't edited but we have a configuration so we can run it as many times as we want now another way that you can run the program is also by re-running so here you can see that we have rerun and then main and if you look carefully we have the keyboard shortcuts as well 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 rerun and you can run so you saw three ways of running your pro oh actually four ways so you can rerun you can run by clicking the play button here when you have a run configuration we can right click and then run main and if we have d so let me actually delete this again so you see so inside of this configuration basically we can add for example environment variables uh interpreter options working directory execution so we can customize this quite a lot right and we can even allow parallel runs so we're not going to mess up with these values so here i'm going to press ok and oh actually what i wanted to do was to delete the configuration so just let me delete and then apply okay and then you can see that now the only the only way that we can run is by right-clicking or we can open up the run tab here right or if we have the main method just like that and now we can run from here so there you have it we've created an application and now you know various ways of running python code with pycharm before we move on with this course i wanna do two things which will benefit you quite a lot so what i'm going to do is to go to pycharm so here at the very top and click on preferences so preferences and you can see the keyboard shortcut so with pycharm there is a keyboard shortcut for everything so you can either click preferences or i'm going to press command and then comma and there we go so this is the interpreter that you saw before and here we can customize the settings right so the first thing that i want to do here is the following go to plugins and in here you can see that we have a list of installed plugins so installed and then these are all the installed plugins by default right so you can see that we have git github mercurial subversion copyright intelligence machine learning uh terminal so basically these are um stuff that comes with pycharm right so what i want to do is switch to marketplace and here we can search for third-party plugins so right here you can see that we have material so this is the actual material theme ui so if you want to experiment with this you can do it but i'm going to show you exactly in a second how to work with themes but what i want to do is i'm going to install this plugin called pre presentation and then assistant and you can see the ratings right here and actually the name is here right presentation assistant so what this plugin allows you to do is to land the keyboard shortcuts and as i teach you throughout this course you will be able to see the keyboard shortcuts that i'm using so go ahead and install there we go and then apply and okay now if they ask you to restart pycharm do so to pick up the changes now let's see whether we have we have it so we have it installed so what i'm going to do here is the following i'm going to right click and then run and now check this out at the very bottom you can see that we have the keyboard shortcut right so this is why i want to make sure that you have presentation assistant so it's really awesome now let's go back to preferences so by charm preferences or keyboard shortcut command and then comma and in here let's search for presentation oh actually not there my bad sorry in here pray oops presentation and then assistant so here it's under appearance and behaviors so right here so here we can customize presentation assistant we can say right you can display for four seconds right here we can even increase the font size so let me say something a little bit bigger so let's say um 60 right so you can see properly and let's change this to five seconds so you see the keyboard shortcuts right and then you can say right you can move it to the right to the top bottom and here right the main key maps you can see here it's 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 in here the alternative key maps is whatever you want right so because i know a lot of you are using mac os or windows right and because i'm on a mac i want to show the alternatives as well for windows users right here and then apply and then okay we're going to come back to that page in a second for key maps now if i right click again and then run you can see the keyboard shortcuts down below and it's taking five seconds and now you can learn about keyboard shortcuts so please make sure to install presentation assistant because it will teach you how to use keyboard shortcuts over time and when you realize you'll be flying using pycharm right the second thing that i wanted to do is to change the key mappings so key mappings is something that you need to decide which key mappings that you prefer so go to settings so command and then comma or pycharm here and then preferences right so actually preferences so here you see that we have key maps so click on that and my key mapping of choice is intellij idea classic so this is what i go for so i've been using intellij so intellij is another ide which is mainly for java development and if you want to learn about intellij i also have a full course on how to use intellij idea but i've been using intellij for quite some time and this is what i prefer right so this is what i'm used to and this is what i feel most comfortable with right because i know every keyboard shortcut if you came from for example sublime text you can choose sublime or emacs you can also choose emacs you can also install extra keymaps so to follow along in this course i highly suggest you to use the same keymaps as as me and you'll see that this is one of the best ones so usually my colleagues and i we have long discussions on which is the best key maps and you know to be honest it's just a pro it's just a personal preference but to follow along in this course choose the intellij idea classic and then apply if you have to now going back to presentation assistant remember so presentation assistant under appearance and behavior presentation assistant so here the key maps is intellij idea classic so this is the one that i'm using so if i apply and then okay now here if i press command and then w and this selects a word you can see the selection right so via command w so i'm going to press command w again and you can see the keyboard shortcut for intellij idea classic as well as for windows so this is something that i needed to set because it's important that you follow along with the exact same key maps if you want to change the key maps there is a short there is a keyboard shortcut and that is control and then tilde so you can see uh right there actually control and then i think it's um it's it's like the the backslash but it's where the tilde is so control and then tilde for me and you can see there the keyboard shortcut and then go to key map and then you can change it like this right so you can say if you're want mac os for example or emacs but the one that we chose was this one here so if i change to mac os now we have mac os so let me change it back so i'm going to use keyboard shortcut so control and then tilde for me and right here i'm going to press 3 so we can even use the the keyboard 3 and then i want 3 again which is the intellij idea classic and there we go so this is how you set your keymaps with pycharm when you're brand new to an ide the first thing that you might want to do is always customize things so we've installed presentation assistant we've set the key mappings and now let's learn how to change the theme so color theme there are things available and it really comes down to personal choice so let's open up settings so i'm going to press command and 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 there we go now in here so appearance and behavior right in here if i expand this and their appearance so here right appearance or in here it's the same thing appearance you can see that we have the theme right here so theme and we have a couple of themes here so we have dracula light intellij light high contrast so on and so forth we also have d so here the font so this is the overall font for your ide it's not the actual text within where you type your code and i'm going to show you that in a second but this is for the overall ide 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 tiny right but i want 42 because i want to see crystal clear so 42 here and here let me just change this to intellij light and then apply and you can see that now everything is white and to be honest the light theme doesn't look that bad but the reason why i don't use it is because if you sit down in front of the screen for many hours it's just going to get your eyes tired so i usually just use the dracula here and then oh actually let me show you the eye contrast first apply and you can see that this looks actually cool as well and mac os lite what's the difference there yeah this is just the mac os theme uh but usually i just go with dracula so here apply so this is the actual theme right now we have the color scheme as well so this is not inside of appearance but it is inside of 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 a very popular one apply and then okay and you can see that now this is the actual quality this is the actual color theme and it's completely different so you might prefer this one because it has a lot of contrast but if i go back so let's try a different one so twilight this is this one is also good you can see that um i actually like this one quite a lot to be honest and let me go back there as well and let me show you one more and usually you will end up playing with all of these color themes apply and this one is not bad actually but to be fair they are all nice so let me go back here and what i'm going to do is just stick with dracula so i'm going to go with the default theme apply and if i go back and open up plugins so here if i type inside of marketplace make sure you are inside of marketplace type theme just like that and you can see that we have a bunch of themes right here so material ui one dark this is from atom i believe dracula and many others right so this is how you install um more themes to python now i'm going to press ok and one tip is if you want to quickly switch themes press ctrl and then tilde so where the tilde key is or the backtick and now check this out we can edit the color scheme so if i press enter you can see that we can choose between those right so if i want monika i just press six and there we go if i go back so control and then backtick and here theme as well so i can press and now i can change right so this is just a quick tip so actually here it even gives you the preview right so light mac os light dracula high contrast so i'm gonna leave the dracula one and then press ctrl tilde or backtick once more and let's go to color scheme once more and here you can if you want github i don't think i've showed you this one but this one is actually all white so it will change everything so if i press yes you can see that this is the github color scheme and it's actually quite nice i'm not going to lie and one thing that i would like to know is which color theme that you prefer so let me know are you a dark or light color scheme guy or girl so if i reverse so i'm gonna go with dark for now so dracula and then yes and there you have it so this is how you go about changing the overall theme with pycharm so if you want to enlarge the font size you can use your mouse so here i'm going to enlarge by using my trackpad and you can see that i'm enlarging things right so this is actually too large or i can just make it smaller and this is the biggest font size that i've that i that i have set so if you want to make it even smaller than this go to preferences so command and comma and then here the cool thing is we can search for font and you can see that we have font size in here so under editor and then font here so you can change the actual font right so you can change between these available ones but i usually just stick with the default it's more than enough and then the size here so if i go to for example 14 or instead let's go 16 here because i think it's it's the one that it accepts and you can see that now this is actually smaller right so this is the 16 um it's actually much smaller because now i can make it smaller right but if i go back here and if i change it to 24 for example and you can see right here so right at the bottom right here you can see the actual size that it looks like so because i've got big monitor i need something big and because i want to teach you pycharm i want you to see everything properly so this is why i crank it up all the way to 50 but you shouldn't need to do it right you shouldn't need to put it all the way to 50. um and the reason why it's not changing for me is because i'm actually enlarging with my mouse like this but if you don't do it you'll actually see um how big and how small it becomes so that's how to change the font size now you see that when we run this program so let's run it again we also have the console font right here so we can also change that so let me go back so command and then comma and then type font so the cool thing is we can always search for things so font and you can see here console font right here and you can either use the defaults and you can basically of maxed out as well to 50 so you can see everything properly but you can go ahead and override and make it look according to your liking so this is how to increase and decrease font sizes with pycharm right now that we have completely set up by charm let's now go ahead and understand exactly how to find things and where things are located so right here you saw that you can run your application from these buttons right here on the top corner right and then this is your configuration basically where you can pass for example environment variables and other things that i've showed you then moving on on the actual menus so you saw that here we have a pycharm and this is where we can access the preferences so you saw it then we have file so this section right here so this is where for example you can create a new file you can create a scratch card a scratch file you can close you can rename the project save all manage id settings and export right so this is the section to go if you need to do any of these then we have edit so edit this is mainly when we are um on the actual ide right so writing code so we can cut we can copy um delete i'm going to show exactly all of these but here you can find for example if you want to find a piece of text you can do it find usages as well so it's very useful and then you have selections extending selections toggle case so for example if you want to have uppercase or not joining lines duplicate sorting and emojis and symbols so don't worry about you know all of these because we're gonna we're gonna dive deep into some of these functionalities and you'll see that we're not even going to use these menus because we're going to learn keyboard shortcuts right so you can see uh right next to every single section uh ev every single menu item here there is a keyboard shortcut right here next we have view so this is where you can um basically enter for example in presentation mode right so for example if you are presenting um if i click there you can see that now this is this is like presentation mode right so there is nothing here and it's actually kind of cool right because i can teach you python like this without without you seeing all the commands um let me actually run and see wow this is actually big right let's not use this for um this course so here let me actually go back appearance and then i can exit and there you have it uh you can also select more than than one um of those appearances right so you've got um zen mode you can exit full screen if you want um and then you have like recent files you can compare and here you've seen that for example if you want to quickly switch your theme this is the keyboard shortcut and you saw how we do it before right then navigation so if you want to navigate your way around finding classes highlighting the next error declaration of usages finding implementations file structure call hierarchy and a bunch of other really interesting things that i'm going to show you through this course then we have code so this is where we can generate some code um for example comment right here it's command and then backs and then forward slash my bad uh if you want to format your code so that that's the command there for example if this is like that and then um just like this if i press command and then option l you can see that it did format the code and you can see formatted one line uh i'm gonna touch on all of that as well then you have refactor so this is where you want to refactor your code uh renaming file so you should really be using these features because they make sure that you you rename across the entire project and not just one file then we have run so this is this is um what you saw before right so where i i told you this is how you run your pro your program but this is another way right you can click on run or actually never go back to run and then you can run but usually i tend not to use um this menu here because there's no need really then you have tools so again uh tools this is more for switching uh uh creating tasks switching tasks saving files as templates and then you have vcs so this is when working for example with git right so any version control you have window so we can restore the layout if you mess up the layout then we can restore and then you have help so in here the cool thing is you can search for anything so if i search for example terminal you can see that it's telling me right so this is the terminal and you can see that it's telling me where it actually lives right so it's under view and then to windows and then terminal right if i say for example rename there you go so you see that rename is in the refactor and then rename so if you want to search sometimes i tend to search like this not not that often and there are better ways of searching but this is one way so there you have it so i just wanted to walk you through these menus because i feel they are really important for you to understand exactly exactly what they mean and as you use pycharm more and more you'll find that you you'll you'll never use these menus because i want to make sure you memorize all the keyboard shortcuts so that you don't have to access um things from within these menus so this is all next let me show you these tabs right here so project structure run problems and all this right so early in this course i told you that if you click on this button right here basically all of those menus they they go away and then this is kind of a more of a distraction free mode right so if you want to access you click there and then it brings up all of these menu all of these tabs actually so let's go one by one and understand what they are so remember i said that if you want to open the project tab so here you press command and then one and you can see the keyboard shortcut down below right so here this is the folder structure for your application so this is where all the python code will go right and then you have external libraries so these are things that you install now what i want you to see here carefully is you see these tabs right here project and structure favorites and then run have a look there is a number right so there is a number there right so what that means is if i press for example here have a look 7 and then structure if i press command and then 7 you can see that open and you can see the keyboard shortcut down below right so command 7 that opens command 7 again that closes command 1 closes the project tab if i want to open the favorites you can see that we have open favorites and this is where we can bookmark things and set favorites within our ide right so command 2 and that goes away if i press command 4 right here you see that it's still run and press command four that opens up and command six that opens up um let's just let justice let this disappeared we can open up the problems so there you have it so i just wanted to show you that if you want to open those you can use the keyboard shortcut instead of manually clicking which is much faster so here you see that you have to do's so there isn't a number here but you can definitely customize it right so to do's are simply a list of the do's that you have within your code so for example here if i was to have a comment and to have a comment i press command and then forward slash and if you forgot just go to help whoops help and then comment and then check this out command with line comment with line comment it's command and forward slash so here i'm going to press command forward slash and here i'm going to type to do and then fix oops fix and then bug and then right here have a look found one to do in file so if i open it up you can see that so let me just expand this it's telling me exactly what it is so line number two and then seven so seven you count you count here so basically is the position right so one two three four five six and then seven this is what it's telling me right so you can see that it's really nice so here if i have another to do and then implement tests right you can see that it's right away so this is how you find your to-do's uh that you have within code and usually um you'll tend to have lots of to-do's because you might have a feature that you don't want to implement now and you might just say right so this is a to do which i need to come back to it later so that's d to do then we have a terminal here so terminal and actually let me let me touch upon terminal next right so on it on a separate video but this is the actual terminal right so um right or or windows is the command line and then you also have the python console here so both are the same and if you want to write some python code here for example i can say print and then hello and then enter you can see that we have hello if i say age equals 2 and then 19 enter now you can see that we have the variable right here so we have tracked of of things i usually don't use this unless i'm actually debugging things and just experiment with with a couple of things for mainly it's mainly like for debugging purposes if i want to test one code but even that i usually write tests and i'm going to show you tests later in this course so that's the python console so if i collapse this and one thing which is really interesting here is let me just show you if for example you decide that you don't like the position of this window right here right so this run window i'm going to take this and then drag it to the side just like that and you can see that now it's on the right hand side here right so you can pretty much just move all of these tabs around if if you don't like their position so usually sometimes i have it like this if i have like a wide screen um [Music] but not that often or sometimes if i'm teaching i i'd like to have for example um the coding section on this side on the left hand side and then the actual result on the right hand side so let me actually go and reset the defaults so window and then here we can restore default layout or shift f12 so let's press shift and then f12 and you can see that we've restored the layout with keyboard shortcuts so there you have it i just wanted to show you these sections right here because they are really important to us and you're going to be using them quite a lot next let me go ahead and teach you about this terminal section right here like many other ides with pycharm you have the terminal as well bundled in so instead of you using your own terminal you can pretty much just use the one that comes with pycharm and what this means it means that you don't have to leave your ide you can do pretty much everything in here so to access just click on terminal and there you have it so here if i type pwd or dir on window so pwd you can see that this is the location for this project right here i have the commands like ls dash al and i can see basically all the files so this is our main dot py so on and so forth so i'm not going to teach you about how to use the terminal or command line because i've got a free course just on that so make sure to check it out if you want to learn how to use it and as you start your career this is a vital skill that you need to have knowing how to use terminal and command line is a must right it's not scary and i break it down step by step for you so what i want to teach you here is that you have a terminal but the cool thing is if you want for example a a new session you can have a new session so here i'm going to press new session and there you have it so maybe on this session you might be running for example a um something in the background where you know you can't really stop it and then on this session you might do like for example you're you're copying files you're moving files so on and so forth right and that is if you need to and for example if you want to run within your terminal if you want to run your application just say python and then main dot py enter and you can see that we get the exact same output right so this is how you run python from within your terminal but obviously i've showed you that we can run it from here right so why would you run it from the terminal so this is all catch me on the next one all right now let me show you how to perform some basic editing with pycharm so let's say that you want to duplicate this line one option is to select the whole line command c and then enter command v and there you go right so that's not the right way of doing it the same if you want to delete this line right i've just selected it and then delete and you can see that it's it's not great right so if you want to duplicate a line press command and then d and you can see that we have duplicated the line if i press again you can see that it's been duplicated and you can see the keyboard shortcuts for windows as well if i want to delete i press command and then y command y to delete a line i can press the app error and then delete and there you have it if you want to undo the changes command z and you can see that it just undo the line right there we go command z so command y to delete and command d to duplicate and if i want to cut the line right so if you want to cut this line so i can paste it somewhere else right i can select it like this and then command and then x so that cuts the line but you saw that we had to select it first right so here what i'm going to do is press so i'm going to press command and then w and i'll check this out this is actually selecting word so i'm going to press command and 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 on expanding expanding expanding and if i want to shrink command shift w and then if i want to delete that i can just delete or if i want to delete the entire line or if i want to cut the entire line right i'll just select everything command and then x so you can see the power of knowing these keyboard shortcuts and if you need help click on the menu and then edit and you can find everything that we've done here right but i'm just teaching you the keyboard shortcuts along the way so that you benefit from it let's say that so here so let's select um everything within double quotes so command w command w and there you have it if i say for example let's say that we have ahmed right ah met so this is a name if i want to put everything in uppercase i want gonna select that so command and then w and then command shift and then u for upper and check this out right so it's just toggle in the case command shift and then u lowercase if i want to lowercase everything here i can press command shift u lowercase everything command shift u again and you can see everything is now uppercase so let me actually undo that one and right here let me just uppercase a command shift u and there we have it now one cool thing here that i want to teach you is let's say that in here you want to have a space right you want to have a space in between line five and line four so that you can write or so that you can type anything right so let's say that you are right here and basically you 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 right so i'm going to press command and then z and what up and what i'm going to do is press command option and then enter and you can see that this is so much quicker right have a look at the keyboard shortcut so let me do it again so even if i'm here command option and then enter and now i can type something here right so this is cool now again command shift command option and then enter and you can see it's just the line above if you want the line underneath you press command shift right so instead of option is command shift and then o there you have it right and this is really cool because now you can see that i don't have to use for i don't have to use the arrows and then um press enter to add a space to add a space or actually a new line so here i can just use the keyboard shortcuts right let's say that um we say print right and let's say that we don't have this line here so we are here and we are saying ah and then med right and you can see that we are missing we are missing the ending parenthesis so what we can do is press the same so command in an option and then enter so that will complete the statement and then move to the next line check this out command shift command shift enter and actually didn't move to the next line so i need to press it again and there you go let's say that you want to indent this file so right here you can see that this is um not well formatted so to format this file you can press option command and then l and you can see that everything is formatted and apart from the last line so i want this like that in fact so if i have another one here for example you can see that that moves it there and here so if i don't have um a new line you can see that this is actually saying that no newline at the end of file and it's saying to reformat the file so that's exactly what i've been doing right so if i press command and then and then option l it formats the file and we are good to go the same if you have some spaces here i think if you have spaces there no because that's part of the string right but i think yeah so i meant outside here right so this is wrong right i mean you can definitely do it but it is wrong but if you want to format everything and maybe have a space here you have another space there and basically this is not right so if you want to format things just press command option and then l and formatted three lines if you want to reorder so if you wanna reorder for example line six with line five you can press shift and then option and then you can reorder like that you can see that i'm moving it up i'm just using the error and you can see the keyboard shortcut down below and i move it down up down just like that search within 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 see that i can use my mouse there or i can press ctrl enter and then python file so i'm just using the keyboard i'm just using my keyboard so python file and let's say that you have utils here and let's have another file so here type math and you can name these um as you want so dot py so i actually 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 by pressing shift two times so shift one shift twice and actually you see so i've typed shift twice but i was too slow so i need to be a bit quicker so there we go this brings this search bar right here so for you you're not going to see it full screen because my font size is like maxed out so for you will be uh smaller but you can see that now i can search literally anything so if i was to say for example print you can see that it's it's searching the entire thing so here i can say for example let me press shift again two times oops there we go so if i search for example git you can see that it's it's searching literally anything and this is why i was telling you that there is a better way of searching and this is like literally you are searching through everything now you can narrow down your searches so for example if you just want classes right you can see that we have classes here we have files symbols and actions so for each of these so if i highlight the all you can see it's a double shift classes is command n files command shift n or shift command n symbols and then actions so you can see the keyboard shortcuts for all of those right so if i want to narrow down so if i press command n you'll see that now it's only searching for classes so if i for example now remove um git right so let's say that i want to search for a class called math just like that and you can see that we found one class called math and this is within our file right so let's within our project actually sorry so if i remove and let's try and search for something that begins with s and have a look we have sanitizers from um python text to speech drivers you might not even see this uh but it's depending on what you have so scanner from json so scanner there you go right so this is how you search for file so you saw that we had math we also had utils so this is how we search so if you want to search for files command shift n right and files is kind of the same thing in python right because technically that's a file but usually for example if you had let's create a new file and here i'm going to say let's say for example students.json right so this is a json file and here let's just be an empty so that it doesn't complain now i can press shift command and then n to search for files and then student and there you have it we're not going to cover um symbols and actions so actions um basically you remember that you saw that we could move a statement up right so that's an action you can technically search for it uh right here and you remember i showed you the keyboard shortcut but you've got many actions right here so let's say that um you know you want to delete for example and there you have it you can see how to delete a line how to delete a word and basically all of these are actions right and you can search for whatever action is available to you so here so search everywhere so that's an action and the cool thing is you get the shortcuts with it right and there you have it that's actions in action so if i say for example scratch card so if i want to create a scratch card so this is like a file which i can use it just for playing around i can do it by using the keyboard shortcut or just use the action so if i press enter here you can see that we can create scratch cards from different languages so python regex xml yamo so on and so forth so there you have it you saw the search functionality it's super powerful and go ahead and practice to become super confident when searching with pycharm let's learn another way of searching with pytram so open up the students.json and right here what i want to do is have for example name a key name and then let's say ali and then comma let's say that ali has cars and this will be an array and for now let's just say bmw and then a tesla let's um actually let's take this object so cut that and this will be an array and i'm going to press option command and then l to indent and you can see that it works with literally anything right and here i'm gonna press comma oh actually let me just take this and then comma here and then paste that there this will be maria and then maria has audi and that's it right she only has one car so now let's learn how to search so basically we've got you know some text that we want to search uh if i open main dot pyth p y you can see that we have some text so previously you saw that we can search by pressing shift n or shift command n or double shift and if i search for let's say maria this is not searching text it's just the searching functionality for classes files symbols and actions right so so here you see that we have all and all searches for everything right but what we want is to search for this word within our ide so let me escape out of this so i'm going to press cape and to search right so let me actually show you so here i can say search i can type find and basically this is what we want so find um we've got the find section so let's go to edit oops edit and then find and you can see that just press command and then f and this will search so if i press shift command f or actually just command f my bad uh if i search for ahmed you can see that it searches for ahmed um if i search for is you can see that we found is if i search for a we have multiple a's and then we have the arrows here so we can find the previous occurrence or so because this is too big is not letting me find the next occurrence right which is the error next to it here which i can't select so you should see it and basically you can search up or down right but the limitation with searching like this is that you you are only searching within this file so if you want to search within everywhere right i'm going to press shift ctrl and then f right so you can see the the keyboard shortcut down below but now check this out if you want to search for maria you can see that it's searching anywhere literally anywhere and here let's search for tesla you can see that we found tesla and it's right here and if i search for is you can see by charm is awesome basically now we are searching through the entire project so this is a much better way of searching you can search in the project module directory and basically you can narrow it down now also here let's say that we want to search right so we want to search for a file mask so you can say right so now i just want to search for anything that ends in json and there you have it so we found our file so let me go ahead and show you again so inside of edit we have find and you can even replace as well right so let's say that i want to replace hello with something else i'm going to press command f and then find and here you can see that basically you can search through a lot of things right you can unselect occurrence as well and you can even find in path and finding path is the one i've just showed you right you can search literally anywhere we also have find usages so this is really cool right so if i select find usages we have nothing but so here let's say that we have def and then add so this takes x and y so it's a function that takes x and y and then return x and then plus and then y so if i format this just like that and then go back to main so i've just pressed ctrl and then tab so that takes me back to the previous file right so you've learned something new now so here what i'm going to do is say add and import i can import right here math.ad and then if i say print and then pass 2 and 2 let me just run it so you see the output so here it's 4 right but now if i go to math dot py and then if i select this method name go to edit find usage and you can see the keyboard shortcut there right and if i select it now you can see that we have one result and it's telling me that here so the ad was the ad was found inside of main.py line number nine and you can see that it's even given me here the code snippet so and i can click on it and navigate straight to it and this is really really cool because if you have a large project you can search you can search usages just like this and also here it shows the usage in the import statement here so math was imported here as well and you can see that it's taking me right here so there you have it what i will do now is to explore these different ways so go to edit find usage and basically they are the same but here you can highlight the usages next highlighted so you can just use the keyboard to to move between the the next and the previous basically and then recent find usages of if i click on that you can see it's pretty much the same thing if you have a large project and you want to find out the recently opened files that you had right how'd you do it right especially if you have like let's say a thousand files and you can see that here this will be like so massive right so if you want to check which was the the the the previously edited file that you had how do you do it so for that you can press command and then e so command e tells you the recent files and you can see here recent files right so all of these files were the ones that i've been through right and here you can show only changed only and it's just showing me that i only changed these files here so this is something to bear in mind and also here it gives you like some shortcut for terminal python console structure which i'm going to show you in a second run and project right so this is recent files if you want recent edited files press shift command e and now you can see or actually recent locations my bad right recent locations you can see that this is where i've been previously it's showing me everywhere here right and this is cool so for you you're going you're going to see this much smaller and for me it's because i've got a large font because i want you to see everything and but yeah but this is how you you search for recent locations so here you know i've been inside of math.py i can click on it and jump into it if i want to see the recent files you can see that math.py was the recent file if i open um let's say that we want to open uh the student students json now if i go to utils.py so this is empty if i press command e you can see that student json comes to the top now if i press command shift e you can see that student json was the recent location here as well and then math.py which you saw and then main.py so there you have it this is how you this is how you search for recent files and locations let me go ahead and show you this awesome way of you drilling down through your python files so we have the structure so this tab right here which i haven't showed you yet so let's have a look on what it does so if i press command 7 you can see that it opens up the file structure so select the main.py for now and then press command and then seven and you can see that this is empty so what this gives us it gives us a view of the fields as well as methods that we have within any python file so here if i go ahead and create a variable so if i say for example name equals to and then empty you can see that we have a v right here so this is indicating that this is a variable if i also so let's let's put the name here gmail for example right so if i have another variable and then here simply say jamila and then name two so you can see that we have name and name too and this is really useful when you have a file which has lots of of variables and functions so here if i for example create a function so if i say def and then hello so this is just for illustration purposes but you can see it's actually saying that we have a function so f for function and named so let's say hello and then here let's say name and you can see that it even tells us that it takes a parameter name so if we say this is a string str uh it doesn't actually tell us but i can say return or actually let's just say print and then name dot and then upper for example right something like that so you can see that we have two variables so name name two and then hello right here you see that low text name now what is cool about it is that i can click on any of these and this will take me right into it so if i press on the first variable you can see that is taking me there variable number two and then hello you can see that this is really really great i use this a lot just to see what the file looks like when when i cannot see everything under one screen right so usually if you have a file that has let's say 100 or 200 lines of code and this is really helpful so that you know exactly how the file is structured so let's open students.json here and here the same so it works brilliantly so here you can see that it's also working with json so here you see that it's telling right this is a json file and then you have two objects and you can even drill down you can see the name if i click on it it takes me to line number three if i click on cars it takes me line number four so this is really really great so one thing which i think is missing here is just the contents inside of this array so if i uh what do i have here so i have math.py so here we have one function that takes x and y and utils.py the structure is empty so this is really awesome when you want to inspect your files another way that you can access this is if you don't want to press command 7 because command 7 will open right on the left panel here so if i collapse this i can press so in here see that we have name and name name and name two and this function here so let's have another function so here so let me just indent this just like that and then say hello to and what i'm going to do is press command and then f12 and the difference here is that this shows up this new window so instead of showing on the left it shows you on this window right here which can be useful so here you can see that this is massive because my phone size is big but for you it might be way smaller and nicer to see so i usually use uh the command f12 because it's easier i can scroll down and i don't have to um use the panel on on on the left hand side so this is my preferred way to use this i can click on it and you can see that that took me right into the hello2 function so this is about the structure tab and functionality within pycharm in this section let's learn about refactoring and how you going to generate code using pycharm so if i cut all of this you saw that when we started this course i told you to type main and you saw that intelligent you saw that pycharm just did its thing right so it just completed code so there are many of these that help you to write code fast so if i paste that in what i want to show you is let's say that we have a class right here so let's have a file actually and this will be person and let's have a class of type person and here let's say that we want to have a constructor now we could go ahead and say underscore underscore init and the score and you might not even know the syntax or what we can do is generate some code i'm going to press control and then enter and now you can see that we can override methods or implement methods and you can see the keyboard shortcuts there so command o for override and to implement so command o and here i can have the constructor there and let's also say that we want to have command o s t r you can see that that's a string representation of an object and i've just wrote like several lines of code by just pretty much just generating code so if i was now to have let's say in here so i can say comma and then name and now i can say self and you can see that this is helping me so self dot and then name equals to name and then here i'm going to return name and then just like that and then check this out i've just added these curly brackets and now if i pass a variable look what's going to happen i'm going to say self and you saw that now we have the f right here so f4 format dot and then name just like this and now i can go back to main and here i can say person person just like that and you know i don't even need to write the import myself because my charm is telling me that i can press so option and then enter and have a look so import right here we're going to import and then person from person and this is just beautiful because we just we're just generating code we're not we're not typing as much and here i'm on the past name so name and then dot and then we have name right but if i now say for example um this is p oh this is alex and let's have this alex oops and then let's print alex so this is the actual object and let me format things run this and now check this out name column and then alex so if you want to learn about classes and whatnot check my course where i cover all of this but i just wanted to show you how to generate some code with pycharm and if you want to learn more about this just go to the menus and then code and have a look so generate code completion optimize imports so on and so forth so there you have it this is how you generate code with pycharm catch me in the next one right let me show you how to extract code with pycharm so extracting is really cool and it allows us to extract code in various different ways so let's say that in here we have this name right here ahmed and we want to extract this to a variable so we could do this we could have um name equals to and then ahmed and then pass oops and then pass name in here right just like that we could do that but this is long-winded so what we can do instead is so i'm going to press command w to select ahmed and then i'm going to press option command and then v and isn't that the same thing and much faster yes and now i can even rename this right so let me just say name here and there you have it we can also extract to a method so here let's take all of this and say that we want a method that does the printing of alex so i'm going to press option command and then m and by the way you can see the keyboard shortcuts down below right or if you're not quite sure of the keyboard shortcuts go to refactor and then here you can see that we have refactor introduce variable constant parameter field method right so this is what i'm teaching you so let's say that we want to have this in into its own method i want to press option command and then m and we're going to give a method name so let's say alex and then method so this is not a good method name but you just get the idea and then okay and now we have a method that does the exact same thing so if i want to put it back if i want to put it back i can in in line so i can press command and then option and then n and this just removes the declaration and i can say refactor and it's just gone back right so command shift n the same here with name i can say right so i i want to inline this option command and n and then inline local variable yes so let me extract this to a variable again so just ahmed there and now this to a method because i want to show you something else so alex method that we had and in here let's say that we want to change this alex right to p we can refactor this by pressing shift and then f6 and what we're going to do here so we're going to say p or we just want to rename code occurrences right we want to rename p here and then we print p and the reason why i'm doing this right so you saw that instead of us changing p here and then p here it just does it for us right and and the renaming thing works for both so here so works both for for variable classes files literally anything anytime that you rename something you should use the rename functionality because it renames across everywhere so keep that in mind so here let's do that again so shift and then f6 and then we want to rename just the code occurrences we don't want to rename the actual variable there because i want to show you something or the actual string so here i want to say p and then what i want to do with this is i want to take this alex and then have that be a parameter that we can then pass as an argument so i'm going to press option command and then p and then check this out so here we're going to say name enter and there you go so that's the default let's say that we don't want the default let's just get rid of that so everything that i'm teaching you is inside of here so extract variable constant field parameter but i'm just giving you the actual examples right so now check this out if i scroll down in here we can say alex or any name right so let's say ali run the program and you can see that we have name ally so there you have it this is how you perform some basic refactor with pie chart it's quite powerful i would encourage you to practice with some examples because you're going to end up using this quite a lot all right so i've showed you how to rename and let me just um show you one more time because i feel it's really important so let's say that we want to rename this file here right so this file map.py which we then import in here now the best way of doing this is if i press shift and then f6 and then let's say that we want to say here you say math and then dash api and you can search for references and comments and also every and also the scope right and this if i select it you see that open files recent change files current file so on and so forth but let me leave it as it is and then we can preview if we want before we refactor or we can just refactor so another another trick here is if i press option you can see that we have these highlightings here right so r and then p which means i can press just with my keyboard r and then that will trigger the refactor if i press p that will trigger the preview so let me do the preview first so p is telling me that you know there is a problem and basically i think there is something weighed when it comes to to renaming uh files with pycharm but let me just cancel out of that so i'm gonna cancel out of that and and just let me give you another example here so if you want to rename ahmed you press shift f6 and then here let's just say name and you see that it updated everywhere the same here so let's say that we want to update that name here i can 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 see where we're going with pycharm right so it's allowing us to be so productive by just using these little tricks so option and then r and you can see that it's showing me the usages and i'm going to say just refactor and i think still doesn't like it so it actually refracted add numbers here so let's check in math.py yes it works but i don't know why um it was complaining but here for example you see that the function name should be lowercase fine let's rename again and you can see renaming in action so here let's just say underscore and then numbers and then refactor here and then do refactor and if we go back to main.py there you have it right one last thing that i want to show you when it comes to refactor is how do we replace things so you've learned how to search and replace so again if i want to search for let's say the word ahmed or the word hello right so i'm going to press command f and then let's search for hello and you can see that we found one occurrence if we want to replace just press command r and we can say replace hello with hello and then world or maybe some spanish hola and here you can see that we can replace and we can also replace all so if we have more than one occurrence we can replace all in one go so let me show you so if i duplicate this and then press command and then f and then r and now we have two occurrences i can replace one by one or replace all so let's just replace all and you can see that's done if i go back so i can replace one by one so here replace one so this line 14 is replaced and then replace again and then zero results so that is awesome so we can also search the way that we've done so here if i press ctrl shift f you can see that we can find in path so hola right but now if i press ctrl shift r it's the same thing we can replace so let's just replace back to yellow or maybe ciao this time right so some italian there and if you remember correctly so replacing path replaces literally everywhere right so let me just show you so here if i go for example to student.json here and let's say that we have maria and then hola right so here i'm searching within this file but i'm going to search um everywhere which is shift ctrl f uh finding path right and if you forgot so go to edit and then find finding path so this is what i'm doing right and you can see here replacing path as well so i'm gonna find in path first and you can even replace at the same time and now actually let's just replace at the same time so edit and then find replacing path we want to replace ola with ciao and you can see that we found both in students json and inside of main right so that's everywhere now we can go and actually i can't see because my uh my font size is too big but you should see a button there that says a button there that says to replace right so let me see if i can press option and then r no that doesn't work here oh actually enter so enter it just works so i've just pressed enter and it's just doing one by one but you should see a button that does the replacement for all instead of one by one enter and there you have it so if i now escape out of this and check this out ciao and if i open students.json we have maria ciao it's not a name let me just delete that and there you have it this is how you 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 that we've done so far if you want to find out the keyboard shortcut you can use the search so here if i press shift two times you can see that we have this searching right and what i'm interested is the actions so to access actions you can press shift command and then a so let me escape out of this and then shift command and then a and just like that so here i can say for example extract method so you've seen this or maybe variable so variable introduced variable here so that's when you extract with variable as well and a bunch of things right so really the keyboard shortcuts is something that you should learn and you know it comes with time and by just watching you're not going to learn it right away right because you need to you know practice and and basically it comes with time so what i say is every time that you want to do something right every time you want to do something try and find the keyboard shortcut for it that's the way that you're going to learn it so pycharm is very powerful and by learning the keyboard shortcuts you will fly with this ide it's just so so powerful so also um you can see that here and on you can see here it gives you suggestions right it tells you right so you should you know rename your variables so you should do things this way or not so for example in this alex method you can see that i've got these yellow lines so if i put my mouse there you can see that function name should be lowercase fine so you can see i can say right give me the more actions right so i'm going to press here in my case option and then enter or you can or you can ignore things like this right but what i'm going to do is actually press command and then enter and then here you can see i can say right i'm going to rename the element and this will be alex underscore and then method and then if i press option and then here you can see that it's highlighted r and i can press r and then do refactor and now it's renamed everywhere so just be aware of those and what you can do right is your mouse right your mouse you see that here i'm using my mouse now you could technically avoid using the mouse as well right if you want to go like this is like becoming a pro but for example right if i want to access this tab right here so the project tab and navigate around if i want to do that how do i do it and then come back to type something so here i'm going to press command and then one so that brings me to the project tab now i'm just going to use the arrows so up r oh actually down arrow and then app arrow right if i want to go back to the editor i just press escape and i see that i'm right here and if i want to close command 1 open just like that so here let's say that we want to open person.py and if i want to go back to typing i just press escape and check this out and there 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 search for a line so i want to see it line oh actually i think it's go to line so go to line right so command and then g so now you see there right i i didn't remember the actual shortcut but now i know that you know if i want to go to a line number i just press command and then g so what i'm going to do here is for example let's say that i was in the project tab so here right i was navigating around then i press um enter so now actually let me just press enter here and then go back so press enter and if i want to go back i just press escape now if i want to go back to line one i could use the up and up and down arrows or i can press command g and now i can go to line one there we go command g again go to line seven for example and you can see the column as well right if you wanted to so here let's say column seven and you can see that i'm right here and this is amazing right so you can use just your keyboard alone if you wanted to right but this is more on the advanced level but as you start learning um pycharm i recommend you to 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 it's here to help you to be more productive right let's learn how to create a simple test with pycharm so when you write code you should really be testing your functionality so it doesn't make sense for you to write some code and then just hope that it works you need to make sure and guarantee that whatever you build it works for different edge cases so with part charm to create tests for your code is very simple let's say that we have a file right here so let's have a python file and we're going to call this as gender and then underscore converter enter and here let's have a function and if you want to learn more about um all of this you can check my course where i teach about functions and whatnot but for now let's have a simple function here and then let's say convert and then underscore and then gender in here we're going to take gender and we're going to say gender equals to and then gender dot and right here you see that we don't have any methods on this and this is because pycharm doesn't know the type of this parameter here so let's say that this is an str so just like that str and now i can say dot and you can see that i can say and then upper so let's uppercase this first and then we're going to say if and then gender equals and then m 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 like that and i'm missing a column there and here as well i'm going to say female and then else we're going to return unknown and then underscore gender and i'm missing a column there and let me format this so command option and then l and there we go so here you see that we have this method let me put it smaller so here we have a method and we want to test this right so 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 up the project right here and then we can right click and then say new python file and then we can say python unit test so this is one way now remember we are all about keyboard shortcuts so if i escape out of this and let's try and use so let me just collapse that and let's use actions so here i'm gonna say unit and then test and let's see if we have anything here so tests so there is no keyboard shortcuts or actually here go to test so here is command and then shift t right go to test so let's actually try that so command shift t so you can see that it says i want to go to test but there isn't one and it's giving me the option to create a test so let's create a test and it's giving you the file name here so test and then gender and then the test class name will be test and then the test function here is test converter gender so that's what we want to test and if i press ok now check this out so it actually generated the test for us so if we were to manually create test we had to we would need to say right so now we need to import unit test from test case and then write a class test pass the test case and then you get the gist right so this is why the you know keyboard shortcuts is just amazing right so now we have some code generator for us so if i go back here so to this gender converter py and let me press again shift command t and now you can see that i do 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 i open up the project tab you can see here so this is the uh oh actually not this one here so this is the actual file that it generated for us next let's go ahead and write a test to test that our code does work right now that we have our test class which has been generated let's write some tests to make sure that the conver gender method does work so here if you've noticed we have these play buttons so let's play these tests so basically it's just a way of running our tests so let's run it and in here you can see that the test did fail so you can see that the right you can see that run one test in 0.003 seconds and then it did fail so in here so actually let me just expand this you can see that this is a test right so this is the test gender converter this is the class and then class test which is this one and then inside we have test gender converter and it was a failure so the reason why it failed is because we have here so you can see that it says self.fail so what we want is to pass so we want to make this test to pass so if i remove this from from there let's see if we can run it like this so you can run every single test within this class or a single test so let's just run it and no tests were found right so what we're going to do here is the following we're going to say self dot and then assert equals and here so we have to pass the arguments so first and second so here let's say that we have so the first argument is hello oh actually let's just say m and then the second one is mail just like that right so let's run the test again and this fails right let's check why and i just i'm actually teaching you some unit testing here right so here you say you see that the assertion failed and this is because it says expected right so we were expecting um m to be equal to male right but it's not equal that's what it's saying here so now if i change this to m and then run it hooray you can see that we have green so one test passed right so what we want to do is use our method so we want to say convert underscore gender and right here you see that we have 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 just pass m right and this gives and then this gives us a gender so what we're going to do here is we're going to say actually so this is the actual result and let's have expected equals to and then mail so now i'm going to say right so i'm going to have the actual here and i'm going to pass expected so let me move this down in here so if i run this and you see that it did pass but we have some red errors here and what is it saying so it's actually saying that this being deprecated so i say equals and it says use assert equal instead fair enough let's use a sir equal and then run again and check this out now everything passed so okay and no errors so this is test so here we are expecting right the output to be male and we know that our method does work so let's say test converter gender and then when male let's grab all of this put it here let's say when female and i just want to say that you know this probably is um is more on the advanced side of things but i'm just showing you the testing functionality within pycharm so here if we pass let's say we pass f right i just want to show you first let's pass f you can see that it failed and this is because so here we are expecting um female but we got male right so let's actually change this to female because we know that we want female here there we go and we can even change this to lowercase f because our function um does an uppercase right so here if i run it you can see that it works and finally let's take everything again so let's just paste everything and then when unknown and here let's say hello just like that and then what we had in our function here was unknown gender so let me grab this and then pause here so this is the expected and let me run you can see that it works right so this is the individual test so you can see that we have so here we have three tests so let's just run all of those and i can expand this and actually let me just say show past and there we go so you can see that we have three tests and some description as well test when female when male and when unknown so this is just an introduction on unit testing with python and pycharm and you can see the functionality of writing tests so it's really cool right so here you can see like the information how many failed how many passed um the runtime and a bunch of other interesting things so i'm not expecting you to know testing and if you're a bit confused just give me a shout i can give you some resources on how to learn testing and testing is something that you um will need to know at some point this is all for now catch me on the next one when you begin your career as a software engineer and writing python code you need to learn how to use any version control such as git so github allows you to store your code in a remote repository where you can work by yourself or with a lot of people right so if you if you work for a company then this is most likely what most companies will be using or maybe another version control such as bitbucket and there are many others right but github is one of the most famous out there so it's very important you know how to use git and github so if i go back to pycharm in here let's access the menu so here remember we saw vcs so basically here we can work with any version control so let's say that you want to enable version control integration for this project right here so my python app so you can click on it and then you see that you can select the actual version control so what we want is git so you will 100 use git unless you are working on some legacy projects but most of the time will be get right so you can say okay now let me cancel out of this first i want to show you something so here if i go to vcs you can see that we have vcs pop-up operations so that's a keyboard shortcut so let me go ahead and press ctrl and then v and there we go right so here i do have all um the options so enable version control create git repository so on and so forth so let's enable git in here so let me just show you again so here i've just selected enable version control and then okay so from this point onwards you can see that everything went red everything went red and this is because now we have these controls here right so we can update the project we can commit and we can push so learning git is out of the scope of this project but i just want to show you that you have the flexibility of committing and pushing code right so if i press ctrl and then v again you can see that the options now are completely different and this is because we enable the version control so here you can see that we can commit we can create a file we can roll back we can push we can stash and stash so on and so forth so to create a file we can press command k the keyboard shortcut is just there so let me press enter and check this out so here you can see that we can browse some files so if i put this figure so we can browse files so here so let's say that we want to add these files right so here right because everything under vn is not hours but all of this is hours and also idea so this is pie chart so this is not ours so we want to add that so we want to add to vcs in here and then i can cancel so now if i open up the project tab you can see that this is green because we've added to vcs and i'm not expecting you to know all of this but i just want to show you that the integration is here so now what i can do is i can push this to a remote branch so if i press ctrl and then v right now here we can push the changes but before what we need to do is actually commit so let's commit this so i've just pressed the commit button there or if i escape out of that and you can see that we can press command zero right or i can press command k and it's the same thing so here for example i could say my and then project and then first commit and then commit we're going to commit this let's just commit that and we have two to-do's remember and we can review them or we can just commit as they are let's commit and there we go so all of that has been committed and you can see that it's no longer green so here you can see that we have another tab here so this is the get one and if i open that up you can see that nelson committed uh five minutes ago and basically these were the changes right um so this is everything that we've committed and you can see the actual message in here my project first commit so if i collapse out of this and you can see also the branch here right you can see the branch which is master and also in here we have the branch so this is the local branch and you can create new branches so here let's say that we want to create a new branch called feature and then dash x create and now we have switched to a new branch so here you can see that now we have two local branches and one final thing that i want to show you is if i now let's say that we have a new method so here let's duplicate this and then say subtract and then here change plus 2 minus just like that so and let me format and now you can see that from line 4 to 7 this is green and this is saying that these are new changes that we have made and you can see the file is blue right math.py so if you want you can roll back the changes so the line everything is gone um let me put it back or if we want now we can say right now let's add this right so this is my change let's say now that we want to commit so this is feature and to subtract numbers there we go we can commit and if i close this now you can see that it's no longer green because we have committed and if i press ctrl v we can push the changes so here we actually have to define remote and add the url that you get from the repository that you create once you are up and running with github or any other version control so i'm going to leave it here because i don't want i don't want us to go out of the scope of this course which is mainly about pycharm but just know that the functionality to work with git and any other version control it's it's actually really really good the idea of pycharm is to give you everything that you need to write and build software without leaving your ide and i think that they have done a very good job with pycharm including all their other ides okie dokie wow you've managed to complete this course and i'm super happy for you so hopefully now you can see the power of pycharm and you know i don't expect you to you know remember everything that we've covered because these things they come when you use more and more and more and practice and practice and practice so what i want to tell you is that you should be trying to use the keyboard shortcuts if you want to do something then maybe perhaps try and use actions right you've learned about actions use actions just to find out what is the keyboard shortcut and then start using the keyboard shortcuts also make sure you have presentation assistant because that way you will remember the keyboard shortcuts much faster and at some point you you will not need it anymore so i've used it before and i recommend you you also use it if you want to learn more about python or are interested in python courses go ahead and check my website where i've got a selection of python courses ready for you this is all for now i had fun teaching you this awesome ide and i'll catch you on the next one
Info
Channel: Amigoscode
Views: 127,679
Rating: 4.9234195 out of 5
Keywords: pycharm tutorial, how to use pycharm, pycharm tutorial beginners, pycharm keyboard shortcuts pycharm, pycharm python, pycharm python tutorial, pycharm tutorial 2020, pycharm installation, pycharm interpreter setup, pycharm debugger tutorial, pycharm vs visual studio code, pycharm tips and tricks, pycharm django, pycharm virtual envrionment setup, pycharm setup, pycharm download, pycharm professional, pycharm student, pucharm vs vscode
Id: hc50ALh_x5g
Channel Id: undefined
Length: 130min 56sec (7856 seconds)
Published: Thu Nov 19 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.