[PyTUT 1] AN INTRODUCTION OF PYTHON

Hi everybody!

Today, I decided to make a series of tutorials in order to introduce Python programming language to beginners.

In this series, I will not get into detail. Instead, I will introduce a decent information to you so that you can use it to build your own applications. On the other hand, in every tutorial, I will recommend some good books to you to improve your knowledge if it is necessary.  OK, let’s take a look at the introduction.

Introduction

Nowadays, Python has been being used widely. According to [1], Python was ranked third among the most popular programming languages in the world in 2016. Its popularity can be explained by 3 main reasons.

The first reason is that Python is a high-level programming language with clear syntax. Thus, user can learn it quickly without any hard efforts (honestly, it is not true if you learn programming language for the first time). However, there are a lot of high-level programming languages and some of theme even more efficient than Python like Julia, why have Python still been a favorite choice? That was caused by a large number of Python communities. A lot of people and organization currently use Python, it means there are a lot of available sources for you when you begin to learn. On the other hand, you can take part in a community and easily find out the solutions by asking the questions if you get troubles. The final reason is that some programming language such as MATLAB or Mathematica may cost you thousand dollars to legally use it, so you may get troubles if you use crack version of these software in your publications. By contrast, Python and most of its library are open-source, so you can use it without any cost. That is also the main reason why I love Python much.

Installation

To install Python, you can access the link: https://www.python.org/downloads/ and choose the version you want to download. After that, run the setup file to install Python in your computer.

installing_python

Fig. 1 The versions of Python

There are two versions of Python: 2.* and 3.*. I prefer to use the version 2.* rather than 3.*, and the version I installed in my computer is 2.7.11. You can choose your favorite verson, but please note that there are a bit different between these two versions.

For example:

  • You can use this syntax for Python 2.* to print the string “My name is Javis” on the screen but cannot use it for Python 3.*.
>>> print "My name is Javis"
  • If you want to print this string on screen by Python 3.*, you have to put the string into the parentheses. The syntax now change a little bit.
>>> print ("My name is Javis")

On the other hand, there are some libraries which can be used in a Python version but cannot be used in the other one. An example of this is that only Python version 3.5 can run TensorFlow library on Window.

Running the first program

After installation, you can run the IDLE which was installed along with Python to write your first program. However, if you do not like using IDLE, you can download the other text editors such as Geany, Spyder, etc or even you can use Notepad to code.

To keep it simple, I will use IDLE of Python version 2.7.11 for this tutorial.

In order to open IDLE on Windows OS, type ‘idle’ in search box and choose IDLE (Python GUI) as Fig. 2.

idle

Fig. 2 Open IDLE of Python 2.7.*

In the screen of IDLE, type the string below:

>>> print "Hello World!"

Then, press Enter, you will see the result as Fig. 3.

python_hello_world

Fig. 2 “Hello World” program

This is the end of this tutorial. In the next tutorial, you will learn how to use numbers and operators in Python.

Hope you enjoy it,

Curious Chick

References

[1] http://spectrum.ieee.org/computing/software/the-2016-top-programming-languages

 

Advertisements

Author: curiouschick

There are many things you may never know about me. But, two things you absolutely know when you visit my blog for the first time: I am a chick and really curious to know everything.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s