Welcome to Python!
Python is a high-level programming language, with applications in numerous
areas, including web programming, scripting, scientific computing, and artificial
intelligence.
It is very popular and used by organizations such as Google, NASA, the CIA,
andDisney.
Python is processed at runtime by the interpreter. There is no need to compile
your program before executing it.
Python is a general purpose, dynamic, high-level, and interpreted programming
language. It supports Object Oriented programming approach to develop
applications. It is simple and easy to learn and provides lots of high-level data
structures.
Python is easy to learn yet powerful and versatile scripting language, which
makes it attractive for Application Development.
Python's syntax and dynamic typing with its interpreted nature make it an ideal
language for scripting and rapid application development.
Python supports multiple programming pattern, including object-oriented,
imperative, and functional or procedural programming styles.
Python is not intended to work in a particular area, such as web programming.
That is why it is known as multipurpose programming language because it can
be used with web, enterprise, 3D CAD, etc.
We don't need to use data types to declare variable because it is dynamically
typed so we can write a=10 to assign an integer value in an integer variable.
Python makes the development and debugging fast because there is no
compilation step included in Python development, and edit-test-debug cycle is
very fast.
Python 2 vs. Python 3
In most of the programming languages, whenever a new version releases, it
supports the features and syntax of the existing version of the language,
therefore, it is easier for the projects to switch in the newer version. However, in
the case of Python, the two versions Python 2 and Python 3 are very much
different from each other.
A list of differences between Python 2 and Python 3 are given below:
1. Python 2 uses print as a statement and used as print "something" to print
some string on the console. On the other hand, Python 3 uses print as a
function and used as print("something") to print something on the
console.
2. Python 2 uses the function raw_input() to accept the user's input. It
returns the string representing the value, which is typed by the user. To
convert it into the integer, we need to use the int() function in Python. On
the other hand, Python 3 uses input() function which automatically
interpreted the type of input entered by the user. However, we can cast
this value to any type by using primitive functions (int(), str(), etc.).
3. In Python 2, the implicit string type is ASCII, whereas, in Python 3, the
implicit string type is Unicode.
4. Python 3 doesn't contain the xrange() function of Python 2. The xrange()
is the variant of range() function which returns a xrange object that works
similar to Java iterator. The range() returns a list for example the function
range(0,3) contains 0, 1, 2.
5. There is also a small change made in Exception handling in Python 3. It
defines a keyword as which is necessary to be used. We will discuss it in
Exception handling section of Python programming tutorial.
the three major versions of Python are 1.x, 2.x and 3.x. These are subdivided
into minor versions, such as 2.7 and 3.3.
Code written for Python 3.x is guaranteed to work in all future versions.
Both Python Version 2.x and 3.x are used currently.
This course covers Python 3.x, but it isn't hard to change from one version
to another.
Python has several different implementations, written in various languages.
The version used in this course, CPython, is the most popular by far.
An interpreter is a program that runs scripts written in an interpreted
language such as Python.
Python Features
Python provides many useful features which make it popular and valuable from
the other programming languages. It supports object-oriented programming,
procedural programming approaches and provides dynamic memory allocation.
We have listed below a few essential features.
1) Easy to Learn and Use
Python is easy to learn as compared to other programming languages. Its syntax
is straightforward and much the same as the English language. There is no use
of the semicolon or curly-bracket, the indentation defines the code block. It is
the recommended programming language for beginners.
2) Expressive Language
Python can perform complex tasks using a few lines of code. A simple example,
the hello world program you simply type print("Hello World"). It will take
only one line to execute, while Java or C takes multiple lines.
3) Interpreted Language
Python is an interpreted language; it means the Python program is executed one
line at a time. The advantage of being interpreted language, it makes debugging
easy and portable.
4) Cross-platform Language
Python can run equally on different platforms such as Windows, Linux, UNIX,
and Macintosh, etc. So, we can say that Python is a portable language. It enables
programmers to develop the software for several competing platforms by
writing a program only once.
5) Free and Open Source
Python is freely available for everyone. It is freely available on its official
website www.python.org. It has a large community across the world that is
dedicatedly working towards make new python modules and functions. Anyone
can contribute to the Python community. The open-source means, "Anyone can
download its source code without paying any penny."
6) Object-Oriented Language
Python supports object-oriented language and concepts of classes and objects
come into existence. It supports inheritance, polymorphism, and encapsulation,
etc. The object-oriented procedure helps to programmer to write reusable code
and develop applications in less code.
7) Extensible
It implies that other languages such as C/C++ can be used to compile the code
and thus it can be used further in our Python code. It converts the program into
byte code, and any platform can use that byte code.
8) Large Standard Library
It provides a vast range of libraries for the various fields such as machine
learning, web developer, and also for the scripting. There are various machine
learning libraries, such as Tensor flow, Pandas, Numpy, Keras, and Pytorch, etc.
Django, flask, pyramids are the popular framework for Python web
development.
9) GUI Programming Support
Graphical User Interface is used for the developing Desktop application.
PyQT5, Tkinter, Kivy are the libraries which are used for developing the web
application.
10) Integrated
It can be easily integrated with languages like C, C++, and JAVA, etc. Python
runs code line by line like C,C++ Java. It makes easy to debug the code.
11. Embeddable
The code of the other programming language can use in the Python source code.
We can use Python source code in another programming language as well. It
can embed other language into our code.
12. Dynamic Memory Allocation
In Python, we don't need to specify the data-type of the variable. When we
assign some value to the variable, it automatically allocates the memory to the
variable at run time. Suppose we are assigned integer value 15 to x, then we
don't need to write int x = 15. Just write x = 15.