Introduction to Python
Python is a general purpose, high-level, interpreted programming language
developed by Guido van Rossum in the late 1980s at the National Research Institute
for Mathematics and Computer Science in the Netherlands.
Python is one of the most popular and widely used programming language used for set
of tasks including console based, GUI based, web programming and data analysis.
Python is a easy to learn and simple programming language so even if you are new to
programming, you can learn python without facing any problems.
Fact: Python is named after the comedy television show Monty Python's Flying Circus.
Features of Python
Python provides lots of features that are listed below.
Easy to Learn and Use
Python is easy to learn and use compared with other programming languages. It is
developer-friendly and high level programming language.
Interpreted Language
Python is an interpreted language because no need of compilation. This makes
debugging easy and thus suitable for beginners.
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.
Free and Open Source
The Python interpreter is developed under an open-source license, making it free to
install, use, and distribute.
Object-Oriented Language
Python supports object oriented language and concepts of classes and objects come
into existence.
GUI Programming Support
Graphical user interfaces can be developed using Python.
Integrated
It can be easily integrated with languages like C, C++, and JAVA etc.
Python Applications
Python is a general purpose programming language that makes it applicable in almost
all domains of software development. Python as a whole can be used to develop any
type of applications.
Here, we are providing some specific application areas where python can be applied.
Web Applications
Desktop GUI Applications
Software Development
Scientific and Numeric
Business Applications
Console Based Application
Audio or Video based Applications
Start Programming with Python
To start programming with python, we have to know some more information. I.e,
installation of python software and execution procedure of python program or script.
There are two major Python versions, those are Python 2 and Python 3. Python 2 and 3
are quite different. This tutorial uses Python 3, because it more semantically correct
and supports newer features.
For installation of python software procedure go through ✍ Python Installation
Tutorial
After successful installation of python software we can able interpret or execute
python script / program.
Python provides us the two ways to run a python script:
Using Interactive interpreter prompt
Using a script file
⇨Using Interactive interpreter prompt:
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 (python3 in case if you have python2 and python3 both installed on your
system).
Through Command Prompt:
(or)
In windows, search for python IDLE in all programs and then click on python IDLE, then
the python interpreter prompt will open.
The Python interpreter prompt look like this
⇨Using Script File:
Interpreter prompt is good to run the individual statements of the code. However if we
want to execute multiple python statements at a time instead of executing one by
one, then we can use script file.
We need to write our script into a file which can be executed later. For this purpose,
open an editor like notepad, create a file named [Link] (python used .py
extension) and write the python script in it.
Example: "[Link]"
print("Hello !")
print("Welcome to Python Programming")
Output: $python3 [Link]
Hello !
Welcome to Python Programming
Comments in Python
In general, Comments are used in a programming language to describe the program
or to hide the some part of code from the interpreter.
Comments in Python can be used to explain any program code. It can also be used to
hide the code as well.
Comment is not a part of the program, but it enhances the interactivity of the program
and makes the program readable.
Python supports two types of comments:
Single Line Comments
Multi Line Comments
1. Single Line Comments in Python:
In case user wants to specify a single line comment, then comment must start with ‘#’
format:
# This is single line comment
Example: "[Link]"
# This is single line comment.
print("Hello Python")
Output: $python3 [Link]
Hello Python
2. Multi Line Comments in Python
Multi lined comment can be given inside triple [Link] must start at begining of
the line.
format:
''' This
Is
Multiline comment'''
Example: "[Link]"
'''This
is
Multi line comment'''
print("Hello Python")
Output: $python3 [Link]
Hello Python
Python Example Program: Demonstrates usage of
Comments in Python
Example: "[Link]"
# This example demonstrates usage of Comments
''' print() used to
print/display
text on screen '''
print("Welcome to Python")
#Assign value to variables
a=20
b=30
#print sum of two numbers
print("Sum is")
print(a+b)