Topic 1: Introduction to Python

Python is a high-level, general-purpose programming language. It supports multiple programming paradigms, including structured, object-oriented and functional programming. It was created by Guido van Rossum, and released in 1991.

Reasons why the python program is very popular:

  1. Easy to learn - because of its compact and English-like code syntax it is very easy to learn. Figure 1.1 shows an example of opening a file in java versus python. In java, more lines of code are required and it's difficult to remember whereas in python it's pretty compact, with fewer lines of code and is extremely easy to remember.

    ...
    Figure 1.1
  2. Libraries - Python has more than 100,000 packages e.g. so let's say if you are working with images then there is pillow if you are a database programmer there is sql alchemy if you are doing scientific computing then there is sci-fi there is NumPy, matplotlib the list just goes on and on top of it.
  3. Code development is faster - you can develop code much faster in python compared to other compiled languages such as java or c++. This is since:
    • syntax and APIs are easily remembered.
    • Python is an interpreted language it doesn't have compilation. It allows one to focus on the real problem remember which speeds up your development by a great amount compared to other programming languages.
  4. Huge collection of the library so one can directly use it from the package available.
  5. Python is heavily used in data science and machine learning due to awesome packages such as sci-kit-learn NumPy sci-fi and pandas.
  6. Job opportunities - there are so many job opportunities available in companies like Google and Facebook which uses Python heavily. It's used in popular websites such as YouTube Quora, Survey Monkey, Dropbox etc which are very high-scale systems.
Integrated Development Environment (IDE)

An integrated development environment (IDE) is a software application that provides necessary tools for computer programmers for software development. It contains both an editor and a compiler. Some examples of Python IDLE include IDLE, PyCharm, Atom, Notebook, VsCode, Vim etc. For this guide, we are going to use PyCharm.

  1. You can download PyCharm from the JetBrains website: https://www.jetbrains.com/pycharm/

    ...
    Figure 1.2
  2. Once you click on download, it will give you two options: Professional or Community. The professional edition of PyCharm requires a subscription, while the Community edition is free. Download the Community edition

    ...
    Figure 1.3
  3. After the download is complete, run the file to install PyCharm. Click on Next on the Welcome to PyCharm Community Edition Setup window.

    ...
    Figure 1.4
  4. The Choose Install Location window allows you the choose a location where the PyCharm would be installed. You can leave it to the default location and just click on Next. However, if you wish to choose another location then use Browse option.

    ...
    Figure 1.5
  5. In the Installation Options window, there are a couple of installation options. You can select three options and leave out Create Associations. Then click on Next.

    ...
    Figure 1.6
  6. Then it will ask you to Choose Start Menu Folder. Keep it to the default setting and just click on Install.

    ...
    Figure 1.7
  7. The installation process will begin.

    ...
    Figure 1.8
  8. In the last setup window, you can choose to Reboot Now and click on Finish to complete the installation. Your computer will restart. You can choose to start later if you wish.

    ...
    Figure 1.9
  1. When you open PyCharm for the very first time, it’ll run you through a couple of dialogue boxes. First, it’ll ask you if you have read and accepted the policy. Read through the entire policy, accept the agreement and click on Continue.

    ...
    Figure 1.10
  2. Then it’ll ask you if they can collect data from you. You can choose your option.

    ...
    Figure 1.11
  3. It’ll go ahead and install the community edition of PyCharm.

    ...
    Figure 1.12
  4. Click on New Project. If you do not have python installed you'll see the small note pop up at the bottom of the dialogue box. However, if you do have python installed that note won't pop up.

    ...
    Figure 1.13
  5. Click on Create which will download and install Python from Python.org. An Installation box will pop up informing us that the Python is installed. It will take a few minutes and after that, it will create a virtual environment and then it’ll be done.

    ...
    Figure 1.14
  6. Once successfully installed, the first project opens up and it comes with example code.

    ...
    Figure 1.15
  7. We can go ahead and run this by simply pressing the green arrow in the top right-hand corner of the screen. As soon as we do this a small box pops up at the bottom and executes the code which in this case is simply a print of the text “Hi PyCharm”. If you see this then the python has been installed in the machine properly.

    ...
    Figure 1.16
  8. You can also go to the start menu and you'll see that among the recently added programs you have the Python Module, IDLE and the python Manual.

    ...
    Figure 1.17
  1. To create a project, do one of the following:
    • From the main menu, choose File | New Project or
    • On the Welcome screen, click New Project

    ...
    Figure 1.18
  2. In the Create Project dialogue, specify the project name and its location. The dialogue may differ depending on the PyCharm edition. Click on Create.

  3. Some existing code will be shown which you can delete and then type print(“Hello World”).

    ...
    Figure 1.19
  4. To run the program click on the green play button on the top right hand corner. As soon as we do this a small box pops up at the bottom and executes the code which in this case is simply a print of the text “Hello World”.

    ...
    Figure 1.20