Pycharm - Understanding Basics



This chapter will discuss the basics of PyCharm and make you feel comfortable to begin working in PyCharm editor.

When you launch PyCharm for the first time, you can see a welcome screen with entry points to IDE such as −

  • Creating or opening the project
  • Checking out the project from version control
  • Viewing the documentation
  • Configuring the IDE
Pycharm Basics

Recall that in the last chapter, we created a project named demo1 and we will be referring to the same project throughout this tutorial. Now we will start creating new files in the same project to understand the basics of PyCharm Editor.

Demo Project

The above snapshot describes the project overview of demo1 and the options to create a new file. Let us create a new file called main.py.

The code included in main.py is as follows −

y = 3

def print_stuff():
   print ("Calling print_stuff")
   print (y)
   z = 4
   print (z)
   print("exiting print_stuff")
	
print_stuff() # we call print_stuff and the program execution goes to (***)
print(y) # works fine
print (z) # NameError!!!

The code created in the file main.py using PyCharm Editor is displayed as shown below −

Main Project

This code can be run within IDE environment. The basic demonstration of running a program is discussed below −

Run Main

Note that we have included some errors within the specified code such that console can execute the code and display output as the way it is intended to.

Display Output
Advertisements