DEV Community

Cover image for Introduction to Python
Sahil
Sahil

Posted on • Originally published at sahilfruitwala.com

Introduction to Python

Past and Present of Python

Guido van Rossum created Python 0.9.0 in 1991. Guido van Rossum began working on Python in the late 1980s, as a successor to the ABC programming language. Python was designed by keeping readability in mind. The construct of Python and its approach to Object-Oriented was aimed to help programmers write clear, logical code for small and large-scale projects.

After Python 0.9.0, major Python versions were developed and released by the Python Software Foundation (starting from 2.1). There are two major Python versions, Python 2 and Python 3. From the higher level, both seem quite the same except for some syntax changes but they are quite different.

Python 2 was released in 2000 with a new number of features, such as list comprehensions and a garbage collection system. Whereas, Python 3 was released in 2008 and was a major revision of the language that is not completely backward-compatible. As per Python Software Foundation guidelines, Python 2 was discontinued with version 2.7.18 in 2020.

Find more details about Python's history on Official Documentation or Wikipedia.

Features of Python

Python is a dynamic, high-level, free open source and interpreted programming language. Python supports object-oriented programming as well as procedural-oriented programming.

The main features of Python are:

  1. Easy to Learn and Use:

Python is easy to learn as compared to other programming languages. Anyone can remember the syntax, rules and regulations of Python very easily.

  1. Expressive Language:

Python can perform complex tasks using a few lines of code.

  1. Platform Independent and Portability:

Python runs in the same manner on different platforms such as Windows, Linux, UNIX, MacOS, etc. The applications which are developed in python on one platform can execute/run on any other platform without making any changes.

  1. Interpreted Language:

In Python, code is executed line by line at a time. Unlike other languages such as C, C++, Java, etc. python does not require compilation of code. As an interpreted language, python code is easy to debug. The source code of python is converted into an immediate form called bytecode.

To learn more about the Difference between Compiled and Interpreted Language you can read this blog on GeeksForGeeks or FreeCodeCamp.

  1. Dynamically Typed Language:

Python does not ask you to declare the type of a variable.

  1. Object-Oriented Language:

Python supports object-oriented approaches and concepts. We can implement OOPs features such as Encapsulation, polymorphic, inheritance, abstraction, etc. in Python.

  1. Large Standard Library:

Python provides a huge number of the in-built library. You can use any of these libraries for your application. You can download and install any third-party modules as well from the Python Package Index.

  1. GUI Programming Support:

You can create Graphical User interfaces (GUI) using modules such as PyQT5, Tkinter and Kivy

  1. Extensible, Integrated and Embeddable:

According to GeeksForGeeks, we can write some Python code into C or C++ language and also we can compile that code in C/C++ language.

We can easily integrated python with other languages like C, C++, etc. Python code can be also embedded in other languages. By embedding, we can provide somewhat scripting capabilities to other languages.

I know this is hard to understand but I just want to show all features. Normally, you will not use this feature.

  1. Free and Open Source & Redistribution:

    Python is freely available and as it is open source, source code is also available to the public. Python has adopted the license so that anyone can use and share it after modification of their own.

By showing you these features, I did not want to overwhelm you. I wanted to show you this to let you know the capabilities of Python. So, in future, you will know for what purpose you can and cannot use Python.

How to Install Python

Finally, Wohooo! A first executable practical step towards Python Programming. So, to download python for your system go to the official Python website and download the latest version. Why the latest version?

So far, python 3 has been backward compatible. It means that you can run code from an older version of Python3 on a newer version of Python3.

Windows Systems

Once you have downloaded the executable python installer (with .msi) extension, open that file and follow the steps shown in the images.

How to Install Python on Windows Step-1

How to Install Python on Windows Step-2

How to Install Python on Windows Step-3

To verify the successful install. Open CMD or PowerShell and write the following commands:

python -V
Enter fullscreen mode Exit fullscreen mode

You will see an output similar to what is shown in the image. Note that, versions can be different. The version will be based on the time you have downloaded python.

Verify Python Installation on Windows

MacOS Systems

After downloading the installer, open that installer and follow the steps shown in the images.

How to Install Python on Mac Step-1

How to Install Python on Mac Step-2

How to Install Python on Mac Step-3

How to Install Python on Mac Step-4

How to Install Python on Mac Step-5

How to Install Python on Mac Step-6

To verify the successful install, open terminal and write the following commands:

python3 -V
Enter fullscreen mode Exit fullscreen mode

You will see an output similar to what is shown in the image. Note that, versions can be different. The version will be based on the time you have downloaded python.

Verify Python Installation on Mac

Linux Systems

Most Debian / Ubuntu / Linux Mint operating systems come with pre-installed python3. To verify if your Ubuntu has python3 installed or not use the following command in the terminal.

python3 -V
Enter fullscreen mode Exit fullscreen mode

Verify Python Installation on Linux

If you don't see any similar output as shown in the image then run the following command in the terminal.

sudo apt update
Enter fullscreen mode Exit fullscreen mode
sudo apt install python3
Enter fullscreen mode Exit fullscreen mode

Redhat / RHEL / CentOS-based operating systems by default come with python 2. To verify python 3 on using the following command:

python3 -V
Enter fullscreen mode Exit fullscreen mode

To install Python 3 use:

yum update -y
Enter fullscreen mode Exit fullscreen mode
yum install -y python3
Enter fullscreen mode Exit fullscreen mode

You will see an output similar to what is shown in the image. Note that, versions can be different. The version will be based on the time you have downloaded python.

Glimpse of Python Code

After the installation and verification process, finally, it is time! Time to run a small piece of code in python.

We will run the old plain program to print Hello World! in Python. To write this code open any text editor or code editor and write the following code:

print("Hello World")
Enter fullscreen mode Exit fullscreen mode

Now, save this file as hello.py and open any terminal in the directory where you saved this file.

If you are on windows write the following code:

python hello.py
Enter fullscreen mode Exit fullscreen mode

On Linux-based systems and Mac, write:

python3 hello.py
Enter fullscreen mode Exit fullscreen mode

You will see an output similar to what is shown in the image.

Glimpse of Python Code


Conclusion

uhhfff, Finally! We are at the end of this section. I know there is a lot in here to process. The features and the installation processes and history. But this is it.

I hope you enjoyed this section and gained some insights into Python.

Make sure to share any thoughts, questions, or concerns. I would love to see them. Let me know if you need any help or want to discuss something. Reach out to me on Twitter, LinkedIn or signup for my Newsletter.

Thank you for your precious time ❤

Top comments (0)