What is PyCharm? All you need to know [OverView]
What is PyCharm

What is PyCharm? All you need to know [OverView]

Last updated on 12th Jul 2020, Blog, General

About author

Manikandan (Application Development Head )

High level Domain Expert in TOP MNCs with 8+ Years of Experience. Also, Handled Around 16+ Projects and Shared his Knowledge by Writing these Blogs for us.

(5.0) | 18907 Ratings 927

The PyCharm IDE is one of the most popular editors used by professional Python developers and programmers. But if you are a beginner, don’t worry, it can help you too! Find out how to create Python projects using PyCharm and what basic features can help you write code more efficiently.

The PyCharm IDE is one of the most popular editors used by professional Python developers and programmers. The vast number of PyCharm features doesn’t make this IDE difficult to use–just the opposite. Many of the features help make Pycharm a great Python IDE for beginners.

If you are just starting to learn Python, you should try out different Python IDEs to see if you prefer working with PyCharm or with another editor.

In my previous article, I showed you how to install the PyCharm IDE on Windows and Ubuntu. In this article, you’ll find out how to create a program and run it using PyCharm. You’ll also get to know some of the features that help beginners write code.

How To Create And Run Python Scripts In PyCharm

    Subscribe For Free Demo

    [custom_views_post_title]

    To create a Python script right click on the project name node and choose from the pop-up menu New › Python File.

    HOW TO CREATE AND RUN PYTHON SCRIPTS

    The New Python file window appears.Enter the name of the file in the Name field.

    NEW PYTHON FILE

    Click OK and you are ready to code in the PyCharm editor.

    WHEN YOU ARE READY TO CODE IN PYCHARM EDITOR

    Copy this example code into the editor:

    def hello():    print(“Hello!”) hello()

    Save the file by clicking on the title tab,

    SAVE THE FILE

    then pressing Ctrl+S or by clicking File › Save All.

    FILE THEN SAVE ALL

    How To Run Python Code In PyCharm

    We can run a project or a single file by selecting the project/file node and choosing from the menu Run › Run (the green Run button) or by using a keyboard combination Alt+Shift+F10.

    The Run window appears:

    HOW TO RUN PYTHON CODE IN PYCHARM

    Click the name of your script.

    At the bottom of the editor the Output window with the result will be shown.

    Course Curriculum

    Start Your Python learning Journey from Python Certification Course

    Weekday / Weekend BatchesSee Batch Details
    OUTPUT WINDOW

    User Interface Of The Editor

    In almost all Python IDEs, the working area is divided into several parts that help make working with files and code more convenient. The screen below illustrates these different parts and what they are doing.

    USER INTERFACE OF THE  EDITOR

    On the top is the main menu, which contains commands like open file, open project, create project or file, run, debug code, etc. Under the main menu is a toolbar with the same functionality, but it provides quick access to these functions. At the bottom is a status bar that displays messages about errors, warnings, and the status of a project. The central part of the screen consists of the editor where you read and write code. To the left, right, and bottom of the editor are tool windows. They allow for many different tasks, for example: see the node of the project and quickly open it, search in files, run options, change debugging settings, etc.

    How To Customize The PyCharm Theme And Color Scheme

    The PyCharm IDE allows you to customize many options. The first custom function is the theme of the IDE. You have a choice among different themes. To access the themes click on File › Settings.

    HOW TO CUSTOMIZE THE PYCHARM THEME

    The Settings window appears. From the left pane, expand the Editor and Color Scheme menus.

    EXPAND THE EDITOR AND COLOR SCHEME

    In the right pane select from the Scheme drop-down list one of the scheme names. For example it may be currently set to the Default scheme. Please note: the default color in PyCharm is Darcula and here, Default means your OS’s default theme.

    DEFAULT COLOR

    Click the OK button.

    SETTINGS

    If the Change PyCharm Theme window appears, click the Yes button. You will see a new theme like this below.

    NEW THEME

    You can also change font colors in the scheme. You’ll find all the available options in the Settings window.

    PyCharm Features With Shortcuts

    Code Highlighting

    The main feature that helps developers in writing code is highlighting. The editor highlights symbols and keywords in the code. It helps a developer to find these words in the script fast and it helps to notice errors. For example strings are green in color, integers are in blue, functions are in dark blue, etc. You can also change colors for groups of words in the settings of the IDE. Syntax highlighting improves the readability of the code.

    CODE HIGHLIGHTING 1

    If you click on the symbol or word, all occurences of this word or symbol will be highlighted.

    CODE HIGHLIGHTING 2

    PyCharm also helps you with errors. If you make a mistake in the code, this word will be indicated by red underlining. Hovering over this word with the mouse displays a tooltip with details.

    CODE HIGHLIGHTING 3

    Code Completion

    Another very important feature, especially if you are just starting to learn Python, is code completion. While writing code you don’t always remember all the keywords in Python. If you start writing a word, the IDE gives you suggestions in a pop-up list, from which you can choose the appropriate word. It’s very convenient.

    You can invoke code completion with the Ctrl+Space command.

    If you write code without importing a required package, you’ll see this underlined in red. Select the word and press Alt+Enter or click the red bulb.

    CODE COMPLETION 1

    The IDE helps by suggesting that you import this package. Click on it and the line containing import will be inserted into the code. Now you can use the code with functions from the package math.

    CODE COMPLETION 2

    PyCharm also helps you remove unused imports if you remove code that depended on a package. If you see an orange bulb, expand it and choose the Optimize imports option.

    CODE COMPLETION 3

    You can do it also by pressing Ctrl+Alt+O or by choosing from the menu Code › Optimize imports.

    Input Definition

    INPUT DEFINITION

    The next helpful feature is the ability to see the definition of a function. If, for example, you type input, but forgot how many and which parameters this function takes, you can display the documentation about this function. Just select the word and choose from the menu View › Quick Definition.

    You can also choose Quick Documentation.

    QUICK DOCUMENTATION

    Expression Type

    Python doesn’t require declaration of data types for variables. However, during writing many lines of code, sometimes you need to find out what data type is assigned to a variable. In PyCharm it is easy. Select the variable and choose from the menu View › Expression type.

    EXPRESSION TYPE

    Of course you can also use the keyboard shortcut Ctrl+Alt+P. In a popup window you see the data type.

    POP UP WINDOW

    Code Folding

    The next useful feature is hiding parts of code. If your code is long, it is very useful to hide sections of code to improve readability. You can select a block of code to hide and choose from the menu Code › Folding › Fold Selection.

    CODE FOLDING

    The selected code will be folded.

    FOLDED CODE

    If you click the plus symbol (“+”), you expand the block of code.

    EXPAND THE BLOCK OF CODE

    Code Constructs With Surround Templates

    PyCharm provides adding surrounding fragments of code with constructs based on the language of the source code like if. For example, you can write only the condition for an if statement and select it.

    Course Curriculum

    Be An Expert in Python with Hands-on Practical Python Training

    • Instructor-led Sessions
    • Real-life Case Studies
    • Assignments
    Explore Curriculum
    CODE CONSTRUCTS WITH SURROUND TEMPLATE

    Then you can choose from the menu Code › Surround With or press Ctrl+Alt+T.

    CODE THEN SURROUND WIDTH

    The list of statements appears.

    LIST OF STATEMENTS

    If you choose if expr, your selected code will be inserted as the condition of an if expression.

    AFTER CHOOSING IF EXPR

    Code Inspection

    In PyCharm you can also easily navigate to the declaration of a variable, function, etc. Select the name of an object and press Ctrl+B. In the screen below we selected the a variable.

    CODE INSPECTION

    PyCharm allows for analysis of code by inspection. It detects compiling errors, unused code, memory leaks, and other problems. By default it analyses all open files and highlights all detected problems. Just select from the menu Code › Inspect Code.

    CODE THEN INSPECT CODE

    The Specify Inspection Scope window appears, where you can choose to inspect all of a project or one file.

    SPECIFY INSPECTION SCOPE

    Click the OK button.

    At the bottom of the IDE you see errors and warnings. In our script there are missing spaces around operators and whitespace before the ‘:’ character.

    INSPECTION RESULTS

    If there are not any errors or warnings, you see a message about it.

    INSPECTION RESULTS 2

    How To Install Packages In The PyCharm IDE

    PyCharm is similar to other Python IDEs in that it allows you to install packages and modules. In PyCharm this is a very easy process. First choose from the menu File › Settings › Project: project name › Project Interpreter

    You will see the Settings window:

    HOW TO INSTALL PACKAGES

    Here is displayed a list of installed packages. To install a new package, click the plus icon, which is next to the names of the columns. The Available Packages window is displayed. Find the package and click the Install Package button at the bottom of this window.

    Pycharm Sample Resumes! Download & Edit, Get Noticed by Top Employers! Download
    INSTALL PACKAGE

    You see the new package in the list.

    NEW PACKAGE

    Click the OK button.You are ready to use the package in your project! 🙂

    Are you looking training with Right Jobs?

    Contact Us
    Get Training Quote for Free