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

Now we will start creating new files in a sample project to understand the basics of PyCharm Editor.

Click on the New Script button to create a new python script file under a default project PyCharmMiscProject. Rename the file to 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