Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
11 views

Lect 1 Introduction To Python

Uploaded by

majilaneeraj257
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

Lect 1 Introduction To Python

Uploaded by

majilaneeraj257
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Introduction to Python

What is Python?
Python is a high-level, interpreted, general-purpose programming language emphasizing on readability
and simplicity. It was created by Guido van Rossum and first released in 1991. Python’s design philosophy
revolves around code readability, notably using significant whitespace. It provides constructs that enable
clear programming on both small and large scales.
High-level language vs low-level language
High-level programming languages are those which are programmer-friendly. Humans can easily
understand it which helps in easy maintaining and debugging of the code. These types of languages need
a compiler or interpreter for execution. High-level languages are the most commonly used languages.
Examples – Java, C, C++, Python
Low-level programming languages are those which are machine-friendly. Humans can’t understand such
languages. In other words, low-level languages are not human-readable. So these languages,
comparatively, are complex to debug. An assembler is required to debug these types of languages.
Examples – Assembly language, Machine language.
Compiler vs Interpreter
All the programming languages are converted to machine-understandable language for execution. The
conversion is taken care of by compilers and interpreters.
Let us consider an example of an Italian movie. For a person, who doesn’t understand Italian and can
understand English, there will be two ways to watch the movie. The first way is to watch an English dubbed
version of the movie, if available. The second way is to watch an Italian movie with English subtitles. In the
second way, the subtitles are displayed scene by scene separately whereas in the first way all the scenes
are converted to English. We can compare the first scenario with the compiler and the second one with
the interpreter.
A compiler is one that takes the source code and converts it into machine-executable code at once. The
processor takes the executable and executes it. The languages which use a compiler are called compiled
languages. Compiled languages are faster and more efficient comparatively.
Examples – Java, C++
An interpreter is one that runs the code line by line and executes instruction by instruction. The languages
which use interpreters are called Interpreted languages. Such languages are slower in terms of execution
and less efficient. Examples – PHP, Python, Ruby
Scripting language
A scripting language is a programming language that is interpreted. These types of languages are used in
automation, etc. These languages use interpreters and are executed line by line.
Definition of Python:
Python is a general-purpose, interpreted, high-level programming language, a Wikipedia definition. In
clear terms, Python is
1. High-level language – It is a human-readable language which easily understandable and easy to debug
2. Interpreted as well as compiled – Python is basically called an interpreted language, but can also be called
a compiled interpreted language. In Python, first, all the source code is at once converted to byte code
which is the action of the compiler, and then the byte code is executed by the compiler.
3. Python is also called a scripting language.

History or Origin of Python

Guido Van Rossum


1. It was invented in the Netherlands in the early ’90s.
2. Guido Van Rossum was the creator of this beautiful language.
3. Guido released the first version in 1991.
4. Python was derived from the ABC programming language, a general-purpose programming language.
5. It is open-source software that can be downloaded freely and the code is customizable as well.

Why the name Python?


There was a TV show by the name Monty Python’s Flying Circus which was a very much popular fun show
in the 1970s. While creating Python, Guido also used to read this show’s published scripts. Guido needed
a short and a different name for this language, hence he named it “Python”.
Python Versions
The following table provides a list of versions released in the Python.

S. No. Version Release Date


1 Python 1.0 January 1994
2 Python 1.5 December 31, 1997
3 Python 1.6 September 5, 2000
4 Python 2.0 October 16, 2000
5 Python 2.1 April 17, 2001
6 Python 2.2 December 21, 2001
7 Python 2.3 July 29, 2003
8 Python 2.4 November 30, 2004
9 Python 2.5 September 19, 2006
10 Python 2.6 October 1, 2008
11 Python 2.7 July 3, 2010
12 Python 3.0 Feb. 13, 2009
13 Python 3.1 June 26, 2009
14 Python 3.2 Feb. 20, 2011
15 Python 3.3 Sept. 29, 2012
16 Python 3.4 March 17, 2014
17 Python 3.5 Sept. 13, 2015
18 Python 3.6 Dec. 23, 2016
19 Python 3.7 June 27, 2018
20 Python 3.7.3 March 25, 2019
Still more versions have been released and the above table is provided with major releases only.

1. Python 1.0V was introduced in Jan 1994


2. Python 2.0V was introduced in October 2000
3. Python 3.0V was introduced in December 2008.
4. The current version is 3.8
Note: Python 3 won’t provide backward compatibility to Python2 i.e. there is no guarantee that Python2
programs will run in Python3.
Features of Python
Key Features of Python:
• Easy to Read and Write: Python is often compared to executable pseudocode due to its clear syntax and
readability, which makes it an excellent choice for beginners in programming.
• Interpreted Language: Python is processed at runtime by the interpreter. You do not need to compile your
program before executing it, unlike languages like C or Java.
• Dynamic Typing: Python is dynamically typed, which means that you don’t have to declare the type of a
variable when you create one. The type is determined at runtime.
• Multi-Paradigm: Python supports various programming paradigms, including procedural, object-oriented,
and functional programming.
• Extensive Standard Library: Python comes with a large library, providing tools suited to many tasks and
reducing the need for external libraries.
• Cross-Platform Compatibility: Python interpreters are available for many operating systems, making
Python programs cross-platform.
• Open Source with a Vibrant Community: Python is an open-source language with an active community
contributing to its development and offering extensive support.
• Wide Range of Applications: Python is used in various domains, such as web development (Django, Flask),
scientific and numeric computing (SciPy, NumPy), desktop graphical user interfaces (Tkinter, PyQt),
software development, and system automation.
• Extensible and Embeddable: Python can be extended with code written in other languages like C or C++,
and it can be embedded in applications written in languages that can call C libraries.
• High-Level Language: Python handles a lot of complexity for the user, so it is very user-friendly because
you do not need to manage the memory yourself, unlike lower-level languages.

Simple: Python syntax is very easy. Developing and understanding python is very easy than others. The
below comparison illustrated how simple python language is when compared to other languages.

Open Source – We can download freely and customize the code as well
Dynamically typed – Dynamically type will be assigned to data. Need not to assign data type to the
variables.
Platform independent: Python programs are not dependent on any specific operating systems. We can
run on all operating systems happily.
Portable: If a program gives the same result on any platform then it is a portable program. Python used
to give the same result on any platform.
Huge library – Python has a big library to fulfill the requirements.
Database connectivity – Python provides interfaces to connect with all major databases like oracle,
MySQL
Batteries included – Python provides inbuilt libraries called batteries. Some of them are below

1. Boto – amazon web services library


2. MySQL-connector-python – To connect with MySQL
3. NumPy – To process arrays
4. Pandas – powerful data structures for data analysis, time series, and statistics

Where is all python used?


Python is being used to develop:
1. Standalone applications: An application that needs to install on every machine to work with that
application.
2. Web applications: An application that follows a client-server architecture. The client is a program, which
sends requests to the server. The server is a program, mainly it can do three things. Captures the request
from the client, process the request, and Sends the response to the client
3. Database applications.
4. To process huge amounts of data. Ex Hadoop, Spark.
5. Machine learning.
6. Artificial Intelligence.
7. Data science.
8. Network servers.
9. IoT
10. Application scripting etc.

Python supports
1. Functional programming as well as Object-oriented programming approach.
2. Initial languages like C, Pascal, or FORTRAN follow functional approaches.
3. C++, Java, and dot net follow an object-oriented approach.
4. Python follows both functional and object-oriented approaches.

Python is an interpreted language


An interpreter is very different from a compiler. An interpreter executes the statements of code “one-by-
one” whereas the compiler executes the code entirely and lists all possible errors at a time. That’s why
python shows only one error message even though your code has multiple errors. This will help you to
clear errors easily.
Keywords in Python
All keywords in python contain only alphabet symbols. All of them are in lower case except True, False,
and None. To see all the keywords –
import keyword;
keyword.kwlist
Keywords – [‘False’, ‘None’, ‘True’, ‘and’, ‘as’, ‘assert’, ‘break’, ‘class’, ‘continue’, ‘def’, ‘del’, ‘elif’, ‘else’,
‘except’, ‘finally’, ‘for’, ‘from’, ‘global’, ‘if’, ‘import’, ‘in’, ‘is’, ‘lambda’, ‘nonlocal’, ‘not’, ‘or’, ‘pass’, ‘raise’,
‘return’, ‘try’, ‘while’, ‘with’, ‘yield’]
Different flavors of python
Flavors of python refer to the different types of python compilers. These are useful to integrate various
programming languages.
1. CPython: Standard python compiler implemented in C language. This is the python software being
downloaded and used by the programmers directly.
2. Jython: Initially called as JPython, later renamed to Jython. Designed to run on a Java program.
3. IronPython: Designed for .NET framework.
4. PyPy: The main advantage of PyPy is performance will be improved because the JIT compiler is available
inside PVM.
5. RubyPython: This is a bridge between Ruby and Python interpreters. It encloses a python interpreter
inside the Ruby application.
6. Anaconda Python: Anaconda is a free and open-source Python programming language. This is mainly for
data science and machine learning-related applications (large-scale data processing, predictive analytics,
scientific computing). This aims to simplify package management and deployment.

You might also like