Lect 1 Introduction To Python
Lect 1 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.
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
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.