Enroll in Selenium Training

In the previous tutorial, we have learned about the fundamental concepts of a programming language. Now, we will learn about the specific programming language called Python. In this article, we are going to learn the following basics of Python language:-

  • Python Basics
    • Features of Python
    • Python2 Vs. Python3
    • Implementations Of Python
  • What Next?

Python Basics:

Python basics

Python is a high-level and object-oriented programming language. It's an open-source language. Guido van Rossum created it in the year 1989. Over the years, many developers all over the world have contributed to Python. Consequently, there are outstanding modules and frameworks in Python which make a life of a Python programmer easy.

You will get to know about Python if you start working with it. Tech giants like Google, Amazon, Youtube, Facebook, etc. are using Python for different purposes. Moreover, Python is one of the most popular languages in 2018 and 2019. And it's going to stay or go high in 2020.

Features of Python

  • Beginner Friendly

    • Python is very handy in terms of learning the syntax. Anyone can quickly learn it's syntax without any difficulty. It's easy to teach. In addition to that, the time required for learning Python is pretty less as compared to other languages.
    • Moreover, the syntax of Python looks like general English.
  • Portability

    • You can run your Python code anywhere irrespective of the machine or software you are using.
    • Moreover, Python follows the statement "code once run everywhere".
    • For example, you have written a program in Windows, and you can use that program to run in Linux as well.
  • Dynamic

    • You don't need to declare the type of an object in Python. In other words, it automatically detects the type of object based on the value that we have given.
    • For example, you can directly assign integers, floats, strings, etc., to variables without bothering about the declaration like C. To clarify, let's see one coding example.
// C code to declare a variable
int main() {
    // variable declaration in C
    int n;
}

# Python code to define a variable
n = 5
  • Open-source

  • It's an open-source language. You can also contribute to the Python project.

  • Standard Library

  • Additionally, Python has a large set of standard libraries that helps you in different aspects.

Python2 Vs. Python3

Developers across the world are adding new features to the Python regularly. Every programming language has some versions. Similarly, Python has versions. We will mainly talk about the Python2 and Python3 in this section.

Python Basics - Python2 Vs Python3

Python is improving the power of syntax to make it easy for programmers. The versions like 2.3, 2.5, 2.7, comes under Python 2, whereas the versions 3.1, 3.7, 3.8, 3.9 comes under Python 3. These are entirely different versions of Python.

Python 3 is a newer and better version of Python 2. If you try to run the Python 2 code in Python 3, then you will get the error and vice versa.  In other words, the syntax of Python 2 and Python 3 has significant differences. You can take them as two different programming languages, though it comes under the same umbrella!

Python versions like Python3.4, 3.7, 3.8 are backward compatible. That is to say; if you have Python 3.4 installed on your PC, then it will work in Python 3.8, as well.

Whenever we talk about the Python in this course, we are referring to Python 3. All the examples that we are examining in this course are in Python 3. Therefore, we recommend you to use the newer version of Python whenever you create a project.

That's it for the variations of Python.

Implementations Of Python

Python language has seen implementation in C, Java, Ruby, and Python itself. As a result, when newer versions of Python are released, then these additional functionalities are implemented in one of these languages. Let's have a quick look at these.

  • CPython - Python was initially developed in C by Guido van Rossum. Still, the developers use C language to add new features to the Python. This implementation of Python is known as CPython. When you run the Python code, it will be executed by the CPython at the machine level. Most of us aren't aware that default Python is also known as CPython. The Python that you download from the official site is  CPython.

cpython-logo

  • Cython - Cython is a C-extension for Python. It's not a Python implementation, but it's entirely a new language. The Cython language is a superset of the Python language that additionally supports calling C functions and declaring C types on variables and class attributes. The syntax of Cython and C is slightly different. You have to work with Python and Cython in the same code. Cython combines Python's ease of use with C performance. Consequently, it helps developers optimize their Python code or create a fast Python interface to their C code.

Cython

  • Jython - Jython is a Java implementation of Python. When any newer version of Python is released, these new features get written in Java. Additionally, if you want to add Python features to the Java code, then CPython is not suitable. For that, we have a Java implementation of Python called Jython. We can add Python flexibility to the Java code.  Jython only supports Python2 as of now.*

Jython

  • PyPy - It is an alternative implementation of Python. It's a python implementation written using Python itself! Moreover, it is a replacement for the CPython. Let's look at some key features of PyPy
    • Speed
      • It's using a Just-in-Time compiler. Additionally, it is swift.
    • Memory
      • It takes less memory compared to CPython. In other words, if a program consumes X MBs in CPython, it will take X/2 in PYPY.
    • Compatability
      • It's highly compatible with the Python. It supports the most popular Python frameworks, like twisted and Django.

pypy

Are you getting overwhelmed with all these options? Well, Don't worry! Just remember that there are different implementations of Python, which are helpful when we need to use Python in a different environment 0(Like Java).

For this course, we will use the default implementation of Python (CPython).

What Next?

Now that you are familiar with the Python Basics. Let's get into some real action. We will start coding from now on. But before we jump in the world of coding, we will quickly show How to install Python and everything else you need to get started with coding!

Happy Coding :)

What is Programming
What is Programming
Previous Article
Install Python
Install Python
Next Article

Similar Articles

Feedback