Chapter 1: Introduction

0 downloads 0 Views 771KB Size Report
In this chapter, you will learn about the python programming language, its history and .... Microsoft Foundation Classes through the win32 extensions. • Delphi.
Chapter 1: Introduction Why to learn this chapter?

In this chapter, you will learn about the python programming language, its history and development, installation guide on your local machine and its applications in various fields.

1. Introduction

Python is one of the great programming language. It is been in service for couple of years now. Python is helpful in number of different tasks i.e. web development, game development, web and mobile application development, GUIs and python is a great language for data science and machine learning. Python is an interpreted general-purpose high level programming language. Guido van Rossum developed python and released it in 1991.

Figure 1: Guido van Rossum (Creator of Python).

1.1 Philosophy behind the Python

Python is a multi-paradigm programming language. Object-oriented programming, structured programming, and many of its features support functional programming and aspect-oriented programming. Many other paradigms are supported via extensions. That is the reason python is widely used in multiple fields of research and development i.e. Bioinformatics, Artificial intelligence, machine learning, data science, robotics, game and web development and in many other fields including hacking. Python’s core philosophy summarized as below     

Beautiful is better than ugly Explicit is better than implicit Simple is better than complex Complex is better than complicated Readability counts

Rather than adding all the functionality into its core, it uses extended interfaces to enhance its functionality to use it in different scenarios. Which makes it different from other programming languages. Python was designed to be highly extensible programming language. This modularity of python makes it one of the highly popular programming language even in 2018.

2. Python installation We now know about python. Now its time to locally install it on your machine to start programming and developing amazing things later on. Follow the installation guide here very carefully to install it on your machine successfully. 1.

Download the package The first step in installation process is to download the compatible python installer file from the web (link given below). https://www.python.org/downloads/

2. Open the installer Now open the installer and install it on your local machine. Then click “Install Now.”

Installation guide 1

Then wait to finish the installation process.

Installation guide 2

Now verify if it is added in your local path. If not added then add the python’s installed directory into your local path. 3. Check the python version Now open the command prompt or CMD and type “python”, it will look like this if correctly configured.

Figure 2: Python version check

2.1 Errors While installing the python on your local machine the possible errors might be because python isn’t added to your local path. So, if that’s the case then follow the following steps. Go to advance system settings Hit Start, type “advanced system settings,” and then select the “View advanced system settings” option. In the “System Properties” window that opens, on the “Advanced” tab, click the “Environment Variables” button.

Installation guide 3: Errors (Go to system settings to set path).

Click the “Environment Variables” button now

Installation guide 4: setting path

As you see in the above picture “path”, click the edit button, then add the “python.exe” path, and save it. Great! Now you can use python from the command prompt or CMD. Now we can use python for research and development purposes. You’ll learn about python in detail with hands on coding examples in later chapters. Which will discuss the use of python in different aspects in detail. Which will provide you hands on learning python experience.

3. Syntax Python’s syntax is simple and very readable. Python is also one of the most easily readable programming language.

Figure 3: Python syntax

It uses English keywords where other programming languages use punctuation. Unlike many other languages, it does not use curly brackets to delimit blocks, and semicolons after statements are optional. It has fewer syntactic exceptions and special cases than other languages like C/C++ or Java. There are two ways to run the python program either saving the file with .py file type for example test1.py is any program saved or running the program directly through interactive python IDLE.

3.1 IDLE IDLE is a simple python integrated development environment available on Windows, Linux, and Macos. Figure 2 shows how IDLE looks like which you can access from the start menu by typing IDLE. Since IDLE is not the best tool for larger programs because it does not provide an option to save the code. IDLE is just a development environment to run the code line by line. However, you can run the saved .py python file through IDLE.

3.2 IDLE’s editor IDLE has an in built editor. Which you can access through IDLE’s menu by clicking on new file. As shown in the figure 4 below. Then you can write your code in the new file and save it with by any name with .py extension. Which you can then run through by clicking the “Run” option in editor’s menu or by simply pressing F5.

Figure 4: IDLE's editor

4. Applications in different fields Python is one of the extensively used programming language. Here we will discuss few of its applications below. 4.1 Web application development Python lets you develop a web application without too much trouble. It has libraries for internet protocols like HTML and XML, JSON, e-mail processing, FTP, IMAP, and easy-to-use socket interface. Yet, the package index has more libraries:  Requests – An HTTP client library  BeautifulSoup – An HTML parser  Feedparser – For parsing RSS/Atom feeds

 

Paramiko – For implementing the SSH2 protocol Twisted Python – For asynchronous network programming

We can also write CGI scripts, and we get advanced content management systems like Plone and Django CMS. 4.2 Python Programming in Desktop GUI Most binary distributions of Python ship with Tk, a standard GUI library. It lets you draft a user interface for an application. Apart from that, some toolkits are available:  wxWidgets  Kivy – for writing multitouch applications  Qt via pyqt or pyside Then we have some platform-specific toolkits:  GTK+  Microsoft Foundation Classes through the win32 extensions  Delphi 4.3 Scientific and Numeric Applications Python is extensity used for scientific and numeric purposes for research and development. For this, we have different python libraries, which are super powers of python.  SciPy: A collection of packages for mathematics, science, and engineering.  Pandas: A data-analysis and -modeling library  IPython: A powerful shell for easy editing and recording of work sessions. It also supports visualizations and parallel computing.  NumPy: lets us deal with complex numerical calculations.  Matplotlib: Data plotting tool. 4.4 Software Development Python serves as a support language in software development. It is used for build-control and management, testing, and for many other things:  SCons – for build-control  Buildbot, Apache Gump – for automated and continuous compilation and testing  Roundup, Trac – for project management and bug tracking.  Roster of Integrated Development Environments 4.5 Python as great language to teach Python is a great choice for teaching (educational purposes) in colleges or universities as a starterprogramming course to learn programming due it its simplicity, readability and extensity. 4.6 Python in Business Python is also a great choice to develop ERP and e-commerce systems:  Tryton: A three-tier, high-level general-purpose application platform.  Odoo: A management software with a range of business applications. With that, it is an allrounder and forms a complete suite of enterprise-management applications in-effect. 4.7 Game development PyGame, PyKyra are two major frameworks for game-development with Python. Apart from these, we also get a variety of 3D-rendering libraries.

4.8 Artificial intelligence and Machine learning Python is also a great language for developing AI and machine learning programs. Large set of python based machine learning libraries serves as a great tool in AI and Ml research and development. Most popular machine learning libraries and frameworks are  TensorFlow  Keras  Theano  Microsoft CNTK  Caffe  Pytorch and more.

Figure 5: Machine-learning frameworks

4.9 Python in Data science Python is one of the great language besides R programming language for data scientists. Data scientist use python as a great tool for their statistical and data exploration tasks using widely available python libraries and frameworks. 4.10 Python for Bioinformatics Powerful, flexible, and easy to use, Python is an ideal language for building software tools and applications for bioinformatics research and development Biopython (Python library for computational biology) is a set of freely available tools for biological computation written in Python by an international team of developers. We will discuss in detail the use of python in bioinformatics in later chapters.

Summary What we learned in this chapter? 1. 2. 3. 4. 5. 6. 7. 8.

We learn about python programming language. Its history and development Philosophy behind its development How to install python on your local machine. Error handling while installing python on your local machine. How to write first python program? Python’s syntax and IDLE And different applications of python.

Workshop exercise: At the end of the chapter, we should do a simple exercise to memorize what we learn in this chapter. 1. 2. 3. 4.

When python was launched? Why python is a great programming language? Different applications of python programming language? Write your first python program, save and run it?

This is the chapter 1: Introduction from the upcoming book titled as “Python for AI, Machine learning and Bioinformatics”. All rights are reserved.

For any suggestions, correction or further information you can connect the author.

Hamza Abdullah

[email protected]