What is Python?

This tutorial is meant for beginners who are just hearing the word Python too often and are wondering what this Python is, mostly high-schoolers who are just starting their BTech. Welcome to the world of programming and technology. This tutorial will be like your introductory brochure into the coding and tech world.

So, when you hear the word Python, what do you think it is? Here is a one-line definition: Python is one of the programming languages. We bet a snake came into your brain. You at least think that there is some link between the name and the snake, but on the contrary, there is no relation between the name Python and a Python snake.

Okay, let us come to the point. What is a programming language? If you already have an idea about the concept, you can skip the next 4 paragraphs. Else, keep reading.

Programming language:

You are hanging out with your friend, and when you want to convey something to your friend, you say it in a language they can understand. A computer is no human. Then, how is it able to understand the commands you give to it?

Right from the moment you turn your computer's switch ON, till you turn it OFF, you give it a lot of commands and every single time how is the computer able to understand? How can it understand to turn ON when you press the ON button?

Though a computer responds to all our commands in English or some other languages, it can't understand the languages we speak. A computer can only understand binary language. Binary language is the language of 0's and 1's. The manufacturer will program every task a computer has to do beforehand on how to react and do the task.

To teach a computer, we neither use a speaking language nor binary language. Instead, we use a programming language. The next paragraph gives you a clear idea; keep reading…

Every task a computer has to do in its lifetime is made into a list of instructions. This set of instructions for every task is called a program, and we, in other words, the manufacturers, write programs using a programming language like C, Python, C++, etc. A programming language is like the common language between users and the computer.

The languages close to the machine's understandability are called low-level languages Ex: Binary language and Assembly language. The languages close to human understandability are called high-level languages, and Python is one of the high-level ones.

Now let's see specifically about Python:

Python is an interpreted language, a high-level and dynamic language. It is easy and simple to learn.

Interpreted language: Programming language where the source code is translated into machine code and executed line by line.

Example: Python, Ruby, JavaScript

Compiled language: Programming language where the entire source code is translated into machine code first in the compilation step and then executed is called a compiled language.

Example: C

If there is an error in line number 10, if it is a compiled language, the compilation stops and the error is raised. But, if it is an interpreted language, the code until line 9 is executed perfectly, and the error is raised.

Dynamic language: A programming language that allows the change in behavior, structure, and type while running.

Example: Python, PHP, Perl

Here is a simple code snippet in Python:

Using the same code in C raises an error as it isn't a dynamic language. In Python, we can reassign the value of a variable as the type of a variable is determined at run time and not at compile time. Observe that we need not write the data type before the variable in the declaration like in C.

Some languages like Python and JavaScript are both interpreted and dynamic, but that doesn't mean that all dynamic languages are interpreted or vice versa. An example of a programming language that is dynamic but not interpreted is Java.

Python has recently become one of the most famous languages due to its vast libraries and options to simplify programmers' tasks. Python is a general-purpose programming language, as its applications are not limited to one specific domain. It is used in various applications, from building websites and apps to testing software. It is almost everywhere, from the recommendation algorithms Netflix uses to autonomous cars. It plays a major role in different technologies, from Artificial Intelligence to Data Science.

A little piece of History:

A Dutch programmer called Guido Van Rossum wanted to take a hobby project to keep him occupied in the Christmas of 1989 in the Netherlands. He was working on a micro-kernel-based distributed system with CWI (Centrum Wiskunde and Informatica) and used the C programming language while working on the project. He felt coding in C was too time-consuming, complex, and lengthy.

Hence, he took a hobby project of creating a simple, readable programming language. He was a huge fan of the BBC television British comedy troupe Monty Python's Flying Circus. He wanted to name his project something simple, catchy, and mysterious, and then he just named it Python, following the "Naming after famous people" tradition.

The language was released on February 20, 1991, as a successor to the ABC programming language. The main objective of Python was to help the programmer be productive. Python 1. x became 2. x, and the currently active updated version is 3.10.4. The two most widely used Python versions were 2. x and 3. x.

Python Syntax compared to C:

1. To print something:

In C:

In Python:

  • See that there is no semicolon at the end and printf is print in Python.
  • The syntax of Python is near to the English language than other languages. Hence, readable.
  • Languages like C use; or parentheses to complete a command. Python uses new lines.
  • Python depends on Indentation with whitespaces to define the scope of blocks of code in the program. Observe that C uses curly braces-{}.

Installation:

These days, many computers and systems come with Python already installed. Before installing Python, you must first check if it is installed in the system.

Steps to check:

  1. Open the start menu
  2. Search for cmd. The command prompt window gets displayed. (cmd.exe)
  3. Type in Python --version or py -version
    What is Python
  4. If you get the version number, Python is already installed on your computer.
    What is Python
  5. If not, you can download it for free from https://www.python.org/
  6. Navigate to the Downloads tab and choose the latest Python 3 version.
  7. Based on the configuration of your system, 32-bit or 64-bit system, download the Windows x86 executable installer or Windows x86-64 executable installer.
  8. After the installer is downloaded, run it. Check the box for Install for all users.
  9. Check the second box if you want your system to recognize Python commands directly without specifying the whole path.
  10. Select Customize Installation. Choose the needed features like Documentation, pip, tcl/tk, and IDLE.
  11. Click Next. Select any advanced options if needed, like creating shortcuts and install. You will see the Setup installation successful window.

Adding Python to the path (If you didn't add the checkbox earlier)(To do it manually)

  1. This is an optional step. If you want Python to be accessible from the command line without providing the whole path, you need to add the path to the System environment variables.
  2. Open the Start menu and search for "Advanced system settings".
  3. Select "View advanced system settings". In the "System Properties" window, click on the "Advanced" tab.
  4. Click on the "Environmental variables" button. In the User Variables section, click on New and create a new variable with the name path and the location of your python file in the C drive as the value.
    What is Python
  5. Verify the installation in the same way you did earlier.

CLI (Command line interface):

Using Python, we can write the code in a text editor like Notepad and run the script in the command line:

  1. Open Notepad, write a python code, and save it with a .py extension.
  2. Open cmd and give the command
    python name.py
  3. The code gets executed, and the output will be displayed in the cmd.

Python is now installed in your system. Now, start with basic elements like data types, arrays, etc., and keep exploring the beauty and simplicity of programming with Python. As mentioned above, Python has vast libraries and functions. When you use a function, consider that you don't have that function and try to meet the functionality just by coding the function yourself.

HAPPY CODING…






Latest Courses