Home »
Python
Introduction to Python
Learn: In this first article we'll discuss about the history, features and applications of the most powerful scripting language. We'll also learn, How to setup Python interpreter(Python Shell)?
By Abhishek Jain Last updated : December 16, 2023
Python Programming Language Introduction
Python is a high-level and object-oriented programming language developed by Guido Van Rossum, when he was working at CWI (Centrum Wiskunde & Informatica) which is a National Research Institute for Mathematics and Computer Science in Netherlands. The language was released in 1991. Python got its name from a BBC comedy series from seventies- "Monty Python's Flying Circus".
How is Python for Development Purpose?
Python is an easy to learn, powerful high-level programming language. It has a simple but effective approach to object-oriented programming. Python's graceful semantics and syntax together with its interpreted nature make it an ideal language for scripting and rapid application development in many fields.
History of Python
Python has its first version as 1.0 in January 1994. The major new features included in this release were the functional programming tools like lambda, map, filter, and reduce.
The last version of Van Rossum was Python 1.2. In 1995, Van Rossum continued his work on Python at the Corporation for National Research Initiatives (CNRI) in Reston.
After that, version 1.4 came into existence, which had several new features. Important among these are the Modula-3-inspired keyword arguments and built-in support for complex numbers. Later in 2001, python evolved with its numerous versions in the 2.0 series among which python 2.7 was the last version which ended in 2010 when python 3.0 came into the market. Even today, the latest version is from the 3rd generation which is python 3.10.
Why Python is so Popular?
Python is an easy and vast language that supports numerous tools and libraries for almost every kind of operation. Apart from the fact that Python is easy to understand and can perform huge calculations, which we cannot even imagine in seconds, python is used in vast areas in which one can work using python.
Today, Python is used in:
- Artificial Intelligence
- Game Development
- Data Analysis and Processing
- Hardware/Sensors
- Internet Of Things
- Web Development
Salient Features of Python
- Easy To Code: As compared to other programming languages like C, C++, and Java. Python keywords are easier to understand and easy to apply and that is the reason python is easy to learn and easy to code when it comes to syntax.
- Object-Oriented: Another essential feature of python is that is an object-oriented language that supports all the OOP concepts like encapsulation, inheritance, abstraction, polymorphism, etc.
- Interpreted Language: Python is a language that runs on an interpreter and it does need compilation, rather, its execution depends on the interpreter which executes it line by line.
- Dynamically Typed: Python is a dynamically typed language which means that any variable in python does not need a predefined data type during the declaration of a variable.
- Dynamic Memory Location: Since python variables are declared without a data type, it means they do not have a fixed memory size and hence if the value for any variable goes beyond the limit, python automatically typecasts the data type.
Major Applications (in Companies):
- In operations of Google search engine, Youtube etc.
- Bit Torrent peer to peer file sharing is written using Python.
- Intel, Cisco, HP, IBM, etc use Python for hardware testing.
- Maya provides a Python scripting API.
- i–Robot uses Python to develop commercial Robot.
- NASA and others use Python for their scientific programming task.
How to get started with python?
The very first step is to get started with Python, your computer is to install the latest version of python from its official website. Now, once python is installed on your computer, you need to create a text file with the extension .py and then run it on an interpreter (since it is an interpreted language). In the interpreter, you just have to move inside the folder where you have saved your file and run your file by mentioning the name of your file with the proper extension.
Several compilers are used for development in Python like PyCharm, Jupiter, and Visual Studio Code. All of these will require an interpreter to execute your python code.
Let us understand the basic syntax structure of Python so that we can create our first python code.
As we know, Python keywords are easier to understand and easy to apply, we will see what we need to use when we want to display something.
The print() function is used in Python to display some output.
First Python Code (Display "Hello World")
# First python code
# Displaying the string Hello World
print("Hello World")
# Output: Hello World
Python Introduction: The Basic Syntax
Python indentation
- Indentation in python is required, it allows you to follow a particular format of code, and also your code looks neat when you use indentation.
- In Python, the expression or statement after every loop or conditional statement will go inside the indentation.
# Python Indentation
if 1>0:
print("1 is greater than 0")
# Output: 1 is greater than 0
The Variables
In Python, variables are created when you assign them some value, apart from this python has no special command to define a variable.
# Python Variable
x = 10
print ("X is :", x)
# Output: X is : 10
The Data Types
In programming, any variable can store different data type values, and also the process of typecasting is allowed. Python has multiple data types which are as follows:
- Numeric: int, float, complex
- Text: string
- Boolean: bool
- Binary: bytes, bytearray
- None Type: NoneType
- Sequence: list, tuple, range
- Mapping: dict
- Set: set
Setting up Python Interpreter
To write and run Python program, we need to have Python interpreter installed in our computer. IDLE (GUI integrated) is the standard, most popular Python development environment. IDLE refers to Integrated Development Environment. It lets edit, run, browse and debug Python Programs from a single interface. This environment makes it easy to write programs.
NOTE: We will be using version 3.6 of Python IDLE to develop and run Python code, in these tutorials. It can be downloaded from www.python.org.
Python shell can be used in two ways, i.e., interactive mode and script mode. Where Interactive Mode, as the name suggests, allows us to interact with OS; script mode let uscreate and edit python source file. Now, we will first start with interactive mode.
Here,
We type a Python statement and the interpreter displays the result(s) immediately.
When we start up the IDLE following window will appear:
Python Tutorial