Main menu

Pages

Getting to know Python right away



Getting to know Python right away



Getting to know Python right away – features, advantages, and use cases

Python (hereafter referred to as Python) has an intuitive and concise syntax, and is the most popular language among programmers as well as non-majors. 

This is because it is used in various fields such as web programming, machine learning at the center of the 4th industrial revolution, Internet of Things (IoT), and data analysis beyond simple utility creation, and it is in close contact with the latest trends.

Below, we will learn about the features, advantages, and use cases of Python.

Introduction to Python

Python is a language developed by a programmer named Guido van Rossum in 1991. It has the characteristics of being able to learn faster than other programming languages ​​thanks to its easy-to-read and easy syntax. Thanks to this, it has gained popularity mainly among non-programmers who do not major in programming, and is being used in various fields from statistics dealing with data analysis and modeling to medicine using deep learning and artificial intelligence.

In the TIOBE index, which surveys programming language preference based on search volume, Python ranked 3rd (10.86%) as the preferred programming language as of February 2021. In one programming language ranking, Python has the most usage, beating Java and C++.

Features of Python

Features 1. Script language

Python is a script language in which an interpreter (interpreter) reads source code line by line and executes it immediately without compilation. As a result, no compilation process is required, so you can easily write code while checking and modifying the execution result.

What is the difference between a compiled language and a scripting language?

A compiled language is a language that translates and executes code written by a programmer (human) into machine language through a process called 'compilation'. 

On the other hand, a script language refers to a language in which the interpreter reads the source code line by line and immediately executes it without a separate 'compilation' process.

Compiled languages ​​take a relatively long time to execute and modify because the source code has to go through the process of compiling, but once translated into machine language, it shows fast execution speed. Because scripting languages ​​run directly without compiling, the results can be checked and modified quickly, but translation and execution are performed at the same time, so the execution speed is slower than that of compiled languages.

Feature 2. Dynamic typing

Python is a dynamically typed language. You can specify a value by simply declaring the variable without specifying the data type. In this case, the data type of the variable is determined at the time the code is executed. It has the advantage of not having to go through a cumbersome process when converting data types, but there is a feature that errors due to unexpected types may occur during code execution.

What is the type (data type) of a variable?

It means that the type of data to be stored in a specific variable is defined in advance. Data types are largely divided into letters and numbers , and numbers are subdivided into integers and real numbers . The value to be stored in a specific variable is divided by type to correspond to the type (data type) of the variable. 

In the case of a statically typed language , the programmer must specify the type (data type) of the data to be entered into the variable, and the type of the variable is determined at compile time. On the other hand, in the case of a dynamically typed language , you can specify a value by declaring only a variable without having to declare the type (data type) of the variable in advance.

Feature 3. Platform-independent

Python works in most Operating Systems (OS), such as Linux, Unix, Windows, and Mac. Since there is no need to compile for each operating system, you can write the source code once and use it on any operating system.

Advantages of Python

Advantages 1. Concise and easy grammar

Python has a syntax similar to human thinking. Therefore, it is possible to learn Python grammar without spending a lot of time, and even people who do not major in programming can learn and use Python within a few days.

The example below shows how easy and concise Python syntax is compared to other programming languages.

EXAMPLE 1. PRINT A SIMPLE PHRASE (HELLO, GABIA!)

C++

#include <iostream>
using namespace std;
int main() {
   cout<<"Hello, gabia!";
   return 0;
}

Java

public class HelloGabia {
   public static void main(String args[]) {
     System.out.println("Hello, gabia!");
   }
}

Python

print(“Hello, gabia!”)


EXAMPLE 2. SIMPLE ARRAY OUTPUT

C++

#include <iostream>
using namespace std;
int main() {
   int arr[5] = {1, 2, 3, 4, 5};
  
   for(int i=0; i<5; i++) {
       cout << arr[i] << endl;
   }
   return 0;
}


Java


public class HelloGabia {
   public static void main(String args[]) {
     int arr[] = {1, 2, 3, 4, 5};
    
     for(int i=0; i<5; i++) {
         System.out.println(arr[i]);
     }
   }
}

Python

arr = [1, 2, 3, 4, 5]
for el in arr:
   print(el)


The code example above shows that Python can do the same with less code compared to C++ and Java.

Advantage 2. Fast development speed

Thanks to its easy and concise syntax, Python is highly productive. With Python, you can do more with less code, and you can develop faster than any other programming language by reducing errors due to complex syntax.

Advantage 3. High scalability and portability

Python corresponds to a typical glue language (or glue language). This is because you can easily access and interoperate with other languages ​​or libraries. If high-performance application development is required, a language such as C/C++ can be used in combination with Python. In this case, the performance of the application can be guaranteed, and at the same time, the advantages of the scripting language can be enjoyed without a separate installation or configuration process.

Advantage 4. A vibrant ecosystem

Python provides a number of standard libraries. This eliminates the need for programmers to write every single piece of code. For example, if you need to connect a specific DB and web server, you just need to use the Python standard library written in the past. It also has the advantage of being able to quickly solve problems and collaborate with a wide ecosystem and active community activities.

Typically, through websites such as PyPI , programmers share their own Python packages, and packages distributed by other developers can be installed simply using the pip command.

Python Use Cases

Many companies are actively using Python to implement different functions. Representative companies that use Python for operating services are as follows.

Google

Google uses a combination of C++ and Python for its backend. In the stack where low latency and strict memory control are important, code is written in C++, and in parts that need fast delivery and maintenance of the program, code is written using Python.

Instagram (Instagram)

Instagram is using the open source web framework Django, written in Python, as its default server-side language.

Netflix

Netflix is ​​actively using Python in its services because of its vast standard library, concise and clean syntax, large community, and rich third-party libraries.

Spotify

Apps from music streaming and media service provider Spotify are built using Python. Spotify engineers have stated that 80% of the Spotify backend is written in Python.

Dropbox

Dropbox, a platform that provides file storage and sharing services such as photos, documents, and more in the cloud, uses Python for both external open source code and its own code.
Dropbox said that the advantages of Python, such as cross-platform support, readability, and ease of learning, made it possible to implement the service quickly. The creator of Python, Guido van Rossum, also worked as a developer at Dropbox from 2012 to 2019.

As you can see, Python is an effective language for people who are new to programming as well as for operating real services.

In the post below, you can practice web parsing using Python.

[Python Practice] Parsing the web using BeautifulSoup and requests

Gavia Python Hosting is a container-based environment within the Docker platform that provides an independent environment for each account.

Comments