Installing and Using Python
Installing and Using Python
First install the latest version of Python, from https://www.python.org/downloads/. At the time of
this writing the latest version is 3.8.1. You will be using Python’s IDLE very little, just to get an
idea of how to use it.
Throughout the course you are going to be using PyCharm IDE, and therefore through this
lecture you will learn how to Install and use PyCharm.
PyCharm Educational Edition is a free editor which you can use for writing Python programs.
Download and install the latest version from https://www.jetbrains.com/pycharm-edu/
From jetbrains.com/education click on Download and then click on Python.
The new window will display the Pycharm logo and the latest version. At the time this document
was written the latest version was 2019.3. Click on Download and follow the instructions to
download PyCharm. On the Installation Options select:
1. 64-bit launcher shortcut,
2. Latest Python version (3.8 or later), and
3. create associations .py
The whole process should not take more than 10 minutes.
Run Pycharm and select:
4. Do not import settings
5. Accept the Privacy Policy
6. Data Sharing – Don’t send
7. Are you a learner or Educator – learner
8. Start using Edu Tools
PyCharm provides you with a better environment to write and run your programs using Python.
The Python Console of PyCharm provides you also the choice to run commands or even
programs using command line.
After you download and install PyCharm, it would be a good idea to create a shortcut on your
desktop.
The next steps will show you the basics of how to use Pycharm to code and run Python
programs.
The first part shows you how to use PyCharm’s IDE and the second the use the Console
Part A- Using PyCharm IDE
You will then be presented with the New Project window. In the Location: text bar, type
H:\Python and click Create. PyCharm will create a Virtual Environment.
With this step you created a project named Python on the H: drive of Centennial College, and
this where you will be saving all your Python files. If you wish, you may select a different drive.
Step 2 – Name your file
You can now start naming and writing the code of you program/file. You can do this in two ways.
1. Right-click on the Python project you created and select New and from there Python File.
You are going to store all your Python files in the project named Python. So, try to give
meaningful names based on the function of the program.
For example the first program you will write, will output the word Hello, thus would be
meaningful to name the file “Hello”.
To give a name to your program, in the Name textbox of the New Python file window, type the
name and hit the <Enter> key.
Step 3 – Type the code
You will now be presented with the PyCharm editor window (top-right pane), where you can
start typing your code.
\
In the editor pane type the statement
print(‘Hello!’)
After you run your file, the program is saved in the project you created with the name Hello.py
Part B – Using PyCharm’s Console
You can use PyCharm’s console to run a single command or even a group of commands.
The triple arrows >>> is the Python’s console prompt, and is the indication that Python Console
is running.
You can now start typing your commands (statements) at the Python Console prompt.
Step 2 – Enter statement
At the prompt (>>>) type print(‘Hello!’) and then hit the <enter> key.
The statement would execute and would display the output on the next line.
It would then display the >>> prompt again so you can enter the next command. The left-bottom
corner of your window should look like the following figure.
Example:
>>> print('What is your name', end=' ') <shift><enter>
… name = input() <shift><enter>
… print('Hi', name+’!’) <Enter>
Find Errors
To find any errors in your code using Pycharm, in the menu bar select
Code | Inspect code…
And then select the file to be inspected