#17 Python Tutorial for Beginners | Working with PyCharm | Run | Debug | Trace | py file

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] welcome back aliens my name is Ivan ready and let's get rid of this series on Python in this point we have seen so many stuff like we have worked with operators we have worked with functions which are inbuilt now it's time to do something big no when I say big I'm not talking about making games or something because it takes time okay I know you people are learning Python so that you can work on big projects but it takes time you have to go step by step if you jumped at the on projects you will get stuck so make sure that you know the basics so in this video let's try to make big code okay so when I say big code till this point we were writing one line of code now it will go for three to four lines of code right so that's a big step but then where to type this code because see whatever we have done till now we were doing it on a interactive console so the thing which we do so which the ideally which you are working with this is your interactive console and whatever you do here that it will give you the instant output right example if I say print and then if I pass a message here which is which is hello and if I say enter you call the output this is interactive console right but then when you work on a project you will write multiple lines of code where do we do it of course you will not be using this pen so you do it right and that's why you will be creating certain files where you write a code but whatever files I'm talking about think about this when you type a document on m/s what do you get dot do see when you when you want a material to read so we prefer PDF so for music we use dot mp3 in the same format for Python we have a file extension plus dot B Y so we have to create a py files how do we do that there are certain steps example you can open notepad that the Col save it as dot demo dot py doesn't matter what's the file name is and then you can run it otherwise what you can do is since we have our IDE available here I will click on file and you can see we have an option of new file so we can write up code here as well better right okay so thanks write the code now simple code of course will go step by step what we'll do let's go with the simplest one which is printing hello that's it think nothing well print hello that's it now what do you think how would you run this code okay now steps before running a code you need to save the goal and how do we do that you simply say control s of course everyone knows that and then you can store this file anywhere you want maybe on cloud storage as well maybe Google Drive or Dropbox but here let's go with the cloud l-dopa one now I will store this file on desktop you can store it anywhere you want but is it easy to access will be desktop so I will go to desktop and on desktop I already have a folder for this Python codes you can create that folder or you can just access a 1x table that works in this folder and then I will create a file I already have a demo file here let's go for some different name I would say this is my code so phylum is my code but then the extension is very important so the extension here is py so we'll go with that extension and I will say save now once you have saved your file it's time to run this so how do you learn this file just go here on run and click on run module this is not the only way to do it there are multiple ways but this is one way let's go with it this way first click on run module and look at your code so on the on the console all on this shell you've got yet output this is hello it works right do we have another way yes we have we can also do that from a command prompt you can go here this is your command prompt and if you can run your code here but how we do that now we can do that with the help of a command called as Python now if you remember when you install Python on your machine and we have done that set path thing if you remember we can do that here we can run that code here now first of all before running a code we have to make sure that you navigate to the folder where you have this file which is Python 7 let me get there so it's a CD desktop now once on I'm in desktop I will navigate to Python codes and you can see I'm doing the folder now and it's time to run this how do we learn this will say python and the file name the file name is my code dot py and that's it say enter that your output right so it works so you can run that on a shell or you can run that on on the command prompt as well your choice of course when you work on a project you will be using IDE something like PyCharm all eclipse because it makes much more sense that but commands and also works let's get back here again we'll go to come on jump after some time but time let's use this one which is this editor now once we got bring hello let's write a big code and I'm gonna say big code let's write the code for three to four lines I want to add two numbers that's it so what I will do is I would say X equal to 5 and Y is equal to 6 so we got 2 values and then I want to add these two values and how do we do that we have done that before oh it says that equal to X plus y and then once you've got the addition it's time to print it let's print it so it's a print Z and that's it save this file and now angle on this you can click on run and you can click on run module or shortcuts you know can you give that f5 so you show going to run every time and one is because see we'd be we want to save our time right simply say f5 and you've got the output mrs. Levin yeah it's working this is one place we can where you can write a code otherwise we can actually use an IDE which is there in our system which is five charm you can use any IDE which you like ok all the codes work on every IDE it's just that everyone have their own preference I prefer JetBrains products my charm is good I also love Eclipse you can try that as well if you want some other IDE which you like which you feel is better try that every code works on all the ideas now how do we work with my charm it's very easy just search up I charm of course I hope you have installed it before and then when you open pycharm it is how this is how it looks like so this is this is the Pronk you will get now how do we get started so of course when you are when you're working with five Chum for the first time you will not get this option of having a project already you need to click on create new project and then here I will enter a project name we can say this is test project so of course when you make a project you will be having a good name but time when test project works I will click on create and you can see we we got pycharm with our project it takes something does take some time to create the environment for you now you can see we got our pie charm and this is how it looks like so when you saw on the left side you can we have a project section so this is where you will see your project folders your project files this is where you would write the code of course you don't have any option of writing code now and this is how you have a panel where you can run the code where you can debug the code and this is where you have you know multiple option example if you want to change this setting you can just go to file and change the setting like you want to change the font size you want to change the color theme because some people they like dark themes you know so you can change that here again we'll go through that but before that I want to create a file here so what we do is I will say right click and say Neal create a file you can create a file or you can create a Python file because Python files will give you the extension dot dot py I would say this is my code again click on OK and you can see I just entered my code look at the extension dot py is by default ok this works let's write the same code in fact I will copy paste the code because I'm lazy to type it copied pasted okay you got your code here now if you want to change the font size it's very easy just go to file and click on setting you can see there's an option of editor font so I was a 25 and click on OK you can see we got the font size of 25 so it is much visible now now we need to run this file right how do we run this it's very easy just click on run and there's option of run the file so you can just click on run my code and you can see the output it's levan if you don't want to do it from here you can just right click and say run my code instead of going up and down and the next time if you want to run this file you can click here turn if you if you make any changes example if I want to change the value from 6 to let's say 8 and if I want to run this code again I can simply click on run button that and it should work you can see we got 13 so it works here in fact you know this is one advantage of using an IDE which is debug now when you say debug you can actually trace what is happening you know how the how your code is changing how value is changing and now let me just do it for you let me show you a magic you can actually see what is happening in the code so first for that first of all you have to add a breakpoint now it is breakpoint breakpoint is something from where you are you can you can trace your code so to get the breakpoint just click on the line number so if you if you want a breakpoint here just click there now once you got your breakpoint you need to go to one and click on debug now my lip lick on debug it will ask you for the file name which is my code and you can see it is it is studied it is it has started the execution now how do you put the next line because see it is only on the first line now right so you just need to type f8 otherwise you can just go to run and say step over but we will press f8 now the moment I press f8 now look at the variable section so in the variable section it says X is of type int and the value is 5 you can actually crack what is happening in fact on the on the here itself you can you can see record x : 5 now it so for this foot it doesn't make any sense because we know the value but when you let's say if you are working on a big project and there's some bug in let's say let's say you have a file of thousand lines ok and there's a bug on line about 28 how would you know that is above on line more 28 so you have to trace right so maybe you know that there is something wrong between line number 20 and 15 but well so you can trace you know you can play put a breakpoint on line number 20 and then you can trace let's press f8 again and you can see we caught y-values 8 let's press f8 now you can see 0 values 13 and then you're printing that value and that's why you want the output right so that's how all these things are working we will be using pycharm a lot so maybe from next videos will be will be focusing more on pycharm maybe we'll go back to IDL a for some code or maybe comment wrong but eventually we'll be using by John so I hope you enjoyed this video working with files and pycharm so if you have any questions let me know in the comment section if you are enjoying this series let your friends knows about this series so do give a thumbs up and subscribe channel if you have not done yet so that's it bye bye you
Info
Channel: Telusko
Views: 763,353
Rating: undefined out of 5
Keywords: telusko, navin, reddy, tutorial, java, python, ide, run, write, debug, code, program, py, .py, file, create, idle, save, cmd, command prompt, addtion, two, number, shortcut, pycharm, project, class, interface
Id: akcEaEH91gI
Channel Id: undefined
Length: 10min 26sec (626 seconds)
Published: Mon Jul 09 2018
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.