PyCharm Tutorial - 7. Debug python code using PyCharm
Key Takeaways
This video tutorial covers the basics of PyCharm, a popular Integrated Development Environment (IDE) for Python, including its elements, debugging concepts, and how to set breakpoints, use watches, and step over functions.
Full Transcript
hello today we are going to get ourself familiar with py charm so if you have watched my previous episode you should have py charm installed on your computer already so just click on it to open it click on create new project and just give a project name to it so since we're writing our first Python program we'll just say first python I have created a c callon code directory you can save this wherever you like create Okay cool so it just created this project called first Python and what we will do is we will add our first python file here so just right click on it new python file let's say you want to write a program to calculate an area of a triangle so just give that name area hit okay and it created area. py file py extension is used for python programs so whenever you're writing any Python program file it will always have py extension so under first Python program now I have this python file called area. py you can can add multiple py files so let's say if you are doing string manipulation and you want to have another strings. py file you can create it and it will add it like like as you see here okay so now you understand the difference or the relation between the project and individual python file project is a container that contains these individual python files okay now let's write our program so if you want to calculate an area of a triangle you need couple of things first thing is your base so what is the base of your triangle so I'm just going to assume let's it's 10 cm so I'll just say 10 and let's say height is five and now to create to calculate area you'll create another variable called area and and if you remember from your high school education the area of a triangle is 1x 2 multiplied by base multiplied by height now one interesting thing that you might have already noticed is when I say at it is giving you this awesome autoc complete with suggestions so it is intelligent enough to know that you have created a variable called height and that's why it is highlighting height so if it is highlighted and if you hit enter it will just type it in for you so you don't have to type in all these different characters so this is like six different characters that you need to type it in but because of this smartness of this IDE you you type h hit enter so your work gets done in basically two keystrokes versus six keystrokes this is extremely use useful in increasing your productivity when you're writing big python programs let's say you're writing let's say 200 lines of Python program this automate complete will help you a lot okay now let's print our area so we'll just say area of our triangle is again I'll use auto complete hit enter okay so now we just wrote Our Python program in order to run it you have to click on run menu hit run and click on area and it just executed it here you see area of triangle is 25 at this stage now I will walk you through different elements of this py charm editor so it has basically basically four different UI elements number one is your Manu so this particular region has all your Manu options and your project name and your python file name second area is called project pan so it is this area where you have your project and list of files you can have multiple projects open as well so this is one project you can you can actually open multiple projects the third area is your code editor this is the most important one this is the place where you will be writing your code the fourth area is your console output so when you run your program the result will go here in this area Okay so these are remember there are like four different areas and you can control the visibility all of these areas by going going under view tools so let's say due to some reason if you're if you go here and click on project if this gets hidden and you're wondering where the thing go and you want to get it back always go into view tool Windows option and click on project and you'll get it back same applies for all this other areas as well okay now let's learn some basic concepts of debugging so what is debugging debug as the word suggest it is a process of finding bug so you are finding a bug and you're fixing it now what is bug bug in any programming language is a problem that you have in your program and things are not working as you expect it to work so you do kind of like thorough analysis of your code and you find out that particular problem IC area and you fix it so that's what is called fixing a bug okay and if you're notice you might have already noticed this icon here there's little bug icon okay so this if you do this it will actually debug so let me first set a break point so breakpoint by setting a break point what you are doing is you're asking a program to stop at particular line and not just execute all at once so when you when you click on run and say run area what you're doing is you're executing all these four lines at once and you immediately see the output let's say my program has some problem and it is not printing expected output so I want to break at particular line and see what's going on so in this area click do left Mouse click and it it will draw this red circle this means you have set a breakpoint here and after that either click on this bug icon to debug it or go to run and click on debug again you have a bug icon here so click here nice so what just happened is our debugging started it started executing this program and it stopped at this very first line which is indicated with this blue background color and you see couple of things here there is a variable pan here there is watches here and I will go over them one by one so you are at base and base variable is still not defined SO watches is used to keep a watch so I want to see what's going on with this base variable when I see hit enter it says it is not defined because you have not executed this line yet so you want to execute it and go to the next line how do you do that you use step over function so either click on this icon it says STS tap over or there is a shortcut called f8 so click here or hit f8 when you do that you come to the second line which means the execution of first line completed and this base which was not defined now it is defined with a value 10 int here means integer in variable pan you will see all the variables of your programs so now you see base here again hit f8 or click on this icon to step over so you see now height is also added here and you can add height if you would like now you might be wondering these two things are same right like kind of same you have base height you have base height but this particular thing is useful because variables will have all the variables so imagine you have 100 variables this list will be long it will be hard to look for the information that you're interested in so in that gue this thing watches becomes pretty useful you can remove all the Clutter and you can add watches on the things that you are interested in looking okay again hit F f8 or step over and it again creates another variable called area and now it has a value 25 so other than these two places it also highlights the values in line in the code editor itself okay here in this area we have console as well as well you are seeing that it has not still printed that statement why because you are at this line you have not passed through that line that's why the console doesn't have the statement so again hit f8 or step into and now you see it it printed that statement because you passed through that line and it ended up in some internal python file that you don't care about so just close it okay so we learned few basic debugging Concepts here one was variable how to watch variables setting explicit watches and how to set a break point Etc okay so this was a little introduction on py Cham different areas and debugging thanks for watching
Original Description
The python video covers how to debug code in Pycharm, what are the elements of PyCharm, basic concepts of debugging, how to set a breakpoint, use of watches and when to use step over function.
Topics that are covered in this Python Video:
0:00 Introduction
0:25 Create new project
4:24 Elements of PyCharm editor
4:32 menu(Dashboard)
4:45 Project panel
5:03 Core editor
5:15 Console output
5:56 Debugging
6:47 Set breakpoint
8:14 Watches
10:09 Step over function
Do you want to learn technology from me? Check https://codebasics.io/ for my affordable video courses.
Video without background music: https://youtu.be/0cQj7q8EWxY
Pycharm is a free code editor for python. In this tutorial we will go over how to debug python code and use various debugging features of pycharm.
Next Video:
Python Tutorial - 8. If Statement: https://www.youtube.com/watch?v=UZRD8rmOC7M&list=PLeo1K3hjS3usILfyvQlvUBokXkHPSve6S&index=9
Website: https://codebasics.io/
Facebook: https://www.facebook.com/codebasicshub
Twitter: https://twitter.com/codebasicshub
Playlist
Uploads from codebasics · codebasics · 7 of 60
1
2
3
4
5
6
▶
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Python Tutorial - 1. Install python on windows
codebasics
Python Tutorial - 2. Variables
codebasics
Python Tutorial - 3. Numbers
codebasics
Python Tutorial - 4. Strings
codebasics
Python Tutorial - 5. Lists
codebasics
Python Tutorial - 6. Install PyCharm on Windows
codebasics
PyCharm Tutorial - 7. Debug python code using PyCharm
codebasics
Python Tutorial - 8. If Statement
codebasics
Python Tutorial - 9. For loop
codebasics
Python Tutorial - 10. Functions
codebasics
Python Tutorial - 11. Dictionaries and Tuples
codebasics
Python Tutorial - 12. Modules
codebasics
Python Tutorial - 13. Reading/Writing Files
codebasics
How to install Julia on Windows
codebasics
Python Tutorial - 14. Working With JSON
codebasics
Julia Tutorial - 1. Variables
codebasics
Julia Tutorial - 2. Numbers
codebasics
Python Tutorial - 15. if __name__ == "__main__"
codebasics
Julia Tutorial - Why Should I Learn Julia Programming Language
codebasics
Python Tutorial - 16. Exception Handling
codebasics
Julia Tutorial - 3. Complex and Rational Numbers
codebasics
Julia Tutorial - 4. Strings
codebasics
Python Tutorial - 17. Class and Objects
codebasics
Julia Tutorial - 5. Functions
codebasics
Julia Tutorial - 6. If Statement and Ternary Operator
codebasics
Julia Tutorial - 7. For While Loop
codebasics
Python Tutorial - 18. Inheritance
codebasics
Julia Tutorial - 8. begin and (;) Compound Expressions
codebasics
Python Tutorial - 12.1 - Install Python Module (using pip)
codebasics
Julia Tutorial - 9. Tasks (a.k.a. Generators or Coroutines)
codebasics
Julia Tutorial - 10. Exception Handling
codebasics
Python Tutorial - 19. Multiple Inheritance
codebasics
Python Tutorial - 20. Raise Exception And Finally
codebasics
Python Tutorial - 21. Iterators
codebasics
Python Tutorial - 22. Generators
codebasics
Python Tutorial - 23. List Set Dict Comprehensions
codebasics
Python Tutorial - 24. Sets and Frozen Sets
codebasics
Python Tutorial - 25. Command line argument processing using argparse
codebasics
Debugging Tips - What is bug and debugging?
codebasics
Debugging Tips - Conditional Breakpoint
codebasics
Debugging Tips - Watches and Call Stack
codebasics
Python Tutorial - 26. Multithreading - Introduction
codebasics
Git Tutorial 3: How To Install Git
codebasics
Git Tutorial 1: What is git / What is version control system?
codebasics
Git Tutorial 2 : What is Github? | github tutorial
codebasics
Git Tutorial 4: Basic Commands: add, commit, push
codebasics
Git Tutorial 5: Undoing/Reverting/Resetting code changes
codebasics
Git Tutorial 6: Branches (Create, Merge, Delete a branch)
codebasics
Git Github Tutorial 10: What is Pull Request?
codebasics
Git Tutorial 7: What is HEAD?
codebasics
Git Tutorial 9: Diff and Merge using meld
codebasics
Difference between Multiprocessing and Multithreading
codebasics
Python Tutorial - 27. Multiprocessing Introduction
codebasics
Python Tutorial - 28. Sharing Data Between Processes Using Array and Value
codebasics
Git Tutorial 8 - .gitignore file
codebasics
Python Tutorial - 29. Sharing Data Between Processes Using Multiprocessing Queue
codebasics
Python Tutorial - 30. Multiprocessing Lock
codebasics
Python Tutorial - 31. Multiprocessing Pool (Map Reduce)
codebasics
What is code?
codebasics
Python unit testing - pytest introduction
codebasics
More on: AI Productivity Tools
View skill →Related Reads
📰
📰
📰
📰
AI tools for Spanish teachers: a practical 2026 guide
Dev.to AI
10 AI Tools That Save Me 20 Hours Per Week in 2026
Dev.to AI
The hard part of a personal memory tool isn’t capture — it’s proving the answer
Medium · AI
El futuro de la automatización SaaS: cómo la IA está redefiniendo la eficiencia empresarial
Dev.to AI
Chapters (11)
Introduction
0:25
Create new project
4:24
Elements of PyCharm editor
4:32
menu(Dashboard)
4:45
Project panel
5:03
Core editor
5:15
Console output
5:56
Debugging
6:47
Set breakpoint
8:14
Watches
10:09
Step over function
🎓
Tutor Explanation
DeepCamp AI