Introduction to Python
Jan 6, 2025 1
What is Python?
Python is a general purpose interpreted
interactive object oriented and high level
programming language.
It was first introduced in 1991 by Guido Van
Rossum , a Dutch computer programmer.
The language places strong emphasis on code
reliability and simplicity so that the programmers
can develop applications rapidly
Jan 6, 2025 2
What is Python?
Python is a high-level programming language which is:
Interpreted: Python is processed at runtime by the interpreter.
Interactive: You can use a Python prompt and interact with the
interpreter directly to write your programs.
Object-Oriented: Python supports Object-Oriented technique of
programming.
Jan 6, 2025 3
Advantages of Python
Most programs in Python require considerably less number of lines
of code to perform the same task compared to other languages like
C .So less programming errors and reduces the development
time needed also.
There are large number of high-level programming languages like
C ,C++,Java etc. But when compared to all these languages
Python has simplest Syntax, availability of libraries and built-in
modules.
Python is also a cross platform language which means that the
code written for one operating system like Windows ,will work
equally well with Linux or MacOS without any changes to the
python code.
Jan 6, 2025 4
Why Python for beginners?
Easy to learn
Easy-to-use syntax
Jan 6, 2025 5
Why Python for beginners?
Stepping Stone to Programming universe
Python's methodologies can be used in a broad range of applications
Rising Demand for Python Programmers
Open- Source, Object Oriented, procedural and
functional
Not only a Scripting language, also supports Web Development
and Database Connectivity
Jan 6, 2025 6
Applications of Python
Machine Learning and Artificial Intelligence
Data Science and Data Visualization
Data Analysis
Web Development
Game Development
3D Graphics
Desktop GUIs
Automations
and many more…
Jan 6, 2025 7
Evolution of Python
Python was developed by Guido van Rossum in
the late eighties and early nineties at the National
Research Institute for Mathematics and Computer
Science in the Netherlands.
Derives its features from many languages like
Java, C++, ABC, C, Modula-3, Smalltalk, Algol-
68, Unix shell and other scripting languages.
Available under the GNU General Public License
(GPL) — Free and open-source software.
Jan 6, 2025 8
Python Features
Python is a High-Level, Interpreted, Interactive and Object -
Oriented Programming Language
Features include:
Easy to Learn and Use
Free and Open-Source
Extensive Standard Library
Cross Platform Compatibility
Interactive Mode
Portable
Embeddable and Extensible
Databases and GUI Programming
Jan 6, 2025 9
Python Features
Python is Interpreted − Python is processed at runtime by the
interpreter. You do not need to compile your program before executing
it.
Python is Interactive − You can actually sit at a Python prompt and
interact with the interpreter directly to write your programs.
Python is Object-Oriented − Python supports Object-Oriented style or
technique of programming that encapsulates code within objects.
Python is a Beginner's Language − Python is a great language for the
beginner-level programmers and supports the development of a wide
range of applications from simple text processing to WWW browsers to
games.
Jan 6, 2025 10
Python Features
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.
Free and Open-Source
Free for anybody to use
Extensive 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, etc.
Jan 6, 2025 11
Python Features
Cross Platform Compatibility
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.
Portable
Python is portable in the sense that the same code can be used on
different machines. Suppose you write a Python code on a Mac. If you
want to run it on Windows or Linux later, you don’t have to make any
changes to it. As such, there is no need to write a program multiple
times for several platforms.
Jan 6, 2025 12
Python Features
Interactive Mode
Python has support for an interactive mode which allows interactive testing and
debugging of snippets of code.
Embeddable and Extensible
Python is an Extensible language. We can write some Python code into C
or C++ language and also we can compile that code in C/C++ language.
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.
Jan 6, 2025 13
Python Features
Databases and GUI Programming
Graphical User Interface is used for the developing Desktop application.
One of the key aspects of any programming language is support for GUI or
Graphical User Interface.
A user can easily interact with the software using a GUI. Python offers various
toolkits, such as Tkinter, wxPython and JPython, which allows for GUI's easy
and fast development.
Python provides interfaces to all major commercial databases.
Jan 6, 2025 14
Python is an interpreted language because programs are
executed by an interpreter.
There are two ways to use the interpreter.
1. Interactive Mode(Command-line mode)
2. Script Mode
Interactive Mode(Command-line mode)
C:\Users>python
Python 3.13.1 (tags/v3.13.1:0671451, Dec 3 2024, 19:06:28)
[MSC v.1942 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more
information.
>>> print(2+3)
5
>>> print("hii")
hii
Interactive Mode(Command-line mode)
Python provides us the feature to execute the python
statement one by one at the interactive prompt.
It is preferable in the case where we are concerned about the
output of each line of our python program.
To open the interactive mode, open the terminal (or command
prompt) and type python.
Then simply type the Python statement on >>> prompt. As we
type and press enter we can see the output in the very next
line.
Advantages of interactive mode
• We get output for every single line of code in interactive
mode i.e. result is obtained after execution of each line of
code.
• It is more preferred by beginners.
• The interactive mode is more suitable for writing very
short programs.
Jan 6, 2025
Disadvantages of interactive mode
• The interactive mode is not suitable for large programs.
• The interactive mode doesn’t save the statements. Once we
make a program it is for that time itself, we cannot use it in
the future. In order to use it in the future, we need to retype
all the statements.
• Editing the code written in interactive mode is a tedious
task. We need to revisit all our previous commands and if
still, we could not edit we need to type everything again.
Jan 6, 2025
Script Mode
Write a program in a file and use the interpreter to
execute the contents of the file.
Such a file is called a script.
Python files have extension .py
Type the following source code in a test.py file:
print("Hello, Python!")
Script Mode
run the program as follows −
python test.py
This produces the following result:
Hello, Python!
Script Mode
Script mode is more suitable for writing long programs.
Editing of code can be easily done in script mode.
Code can be saved and can be used in the future.
It is more preferred by experts than the beginners to use
script mode.