Introduction to Python | DevsDay.ru

IT-блоги Introduction to Python

dev.to 4 октября 2021 г.


Outline

  1. Past and Present of Python
  2. Features of Python
  3. How to Install Python
  4. Glimpse of Python Code
  5. Conclusion

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.
  2. Expressive Language Python can perform complex tasks using a few lines of code.
  3. 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.
  4. 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.
  2. Object-Oriented Language Python supports object-oriented approaches and concepts. We can implement OOPs features such as Encapsulation, polymorphic, inheritance, abstraction, etc. in Python.
  3. 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.
  4. GUI Programming Support You can create Graphical User interfaces (GUI) using modules such as PyQT5, Tkinter and Kivy
  5. 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.

Windows Installation

Windows Installation

Windows Installation

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

python -V

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 download python.

Windows Installation

MacOS Systems

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

Mac Installation

Mac Installation

Mac Installation

Mac Installation

Mac Installation

Mac Installation

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

python3 -V

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 download python.

Mac Installation

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

Ubuntu Installation

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

sudo apt update
sudo apt install python3

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

python3 -V

To install Python 3 use:

yum update -y
yum install -y python3

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 download python.

Glimpse of Python Code

After the installation and verification process, finally, it is the 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")

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

On Linux based systems and Mac, write:

python3 hello.py

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

Test Python

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.

If you liked this, share with your friends or colleague who wants to learn Python as well. If you have any questions or doubt mention them in the comment section or reach out to me on Twitter, LinkedIn or Instagram.

Thank You for your time ❤

Источник: dev.to

Наш сайт является информационным посредником. Сообщить о нарушении авторских прав.

tutorial python beginners machinelearning