Python
Programming Notes and Practical Programs BCA 3rd Semester CSJM
University Kanpur
Python is a very
simple yet very powerful object oriented programming language.
Introduction to Python Programming language
Python
is developed by Guido van Rossum. Guido van Rossum started
implementing Python in 1989. Python is a very simple programming language so
even if you are new to programming, you can learn python without facing any
issues.
Interesting
fact:
Python is named after the comedy television show Monty Python’s Flying Circus.
It is not named after the Python snake.
Features
of Python programming language
1. Readable: Python is a very readable language.
2. Easy
to Learn: Learning python is easy as this is a expressive and high
level programming language, which means it is easy to understand the language
and thus easy to learn.
3. Cross
platform: Python is available and can run on various operating systems
such as Mac, Windows, Linux, Unix etc. This makes it a cross platform and
portable language.
4. Open
Source: Python is a open source programming language.
5. Large
standard library: Python comes with a large standard library that has
some handy codes and functions which we can use while writing code in Python.
6. Free: Python
is free to download and use. This means you can download it for free and use it
in your application. See: Open Source Python License. Python is an example
of a FLOSS (Free/Libre Open Source Software), which means you can freely
distribute copies of this software, read its source code and modify it.
7. Supports
exception handling: If you are new, you may wonder what is an
exception? An exception is an event that can occur during program exception and
can disrupt the normal flow of program. Python supports exception handling
which means we can write less error prone code and can test various scenarios
that can cause an exception later on.
8. Advanced
features: Supports generators and list comprehensions. We will cover
these features later.
9. Automatic
memory management: Python supports automatic memory management which
means the memory is cleared and freed automatically. You do not have to bother
clearing the memory.
What Can
You Do with Python?
You
may be wondering what all are the applications of Python. There are so many
applications of Python, here are some of the them.
1. Web development – Web framework
like Django and Flask are based on Python. They help you write server side code
which helps you manage database, write backend programming logic, mapping urls
etc.
2. Machine learning – There are many
machine learning applications written in Python. Machine learning is a way to
write a logic so that a machine can learn and solve a particular problem on its
own. For example, products recommendation in websites like Amazon, Flipkart,
eBay etc. is a machine learning algorithm that recognizes user’s interest. Face
recognition and Voice recognition in your phone is another example of machine
learning.
3. Data Analysis – Data analysis and
data visualization in form of charts can also be developed using Python.
4. Scripting – Scripting is writing
small programs to automate simple tasks such as sending automated response
emails etc. Such type of applications can also be written in Python programming
language.
5. Game development – You can develop games
using Python.
6. You can develop Embedded
applications in Python.
7. Desktop applications – You can develop desktop
application in Python using library like TKinter or QT.
PyCharm Python IDE in Windows, Mac OS X, Linux/Unix
PyCharm (a popular IDE for Python programming)
If
you are new to programming then you may be wondering what do we mean by IDE?
IDE stands for integrated development environment.
It is a software that consolidates the basic tools that are required to write
and test programs in a certain language. Typically, an IDE contains a code
editor, a compiler or interpreter and a debugger that you can access at the
same place through IDE GUI.
How to
Install Python
You can install Python on any operating system such
as Windows, Mac OS X, Linux/Unix and others.
To
install the Python on your operating system, go to this link: https://www.python.org/downloads/.
You will see a screen like this.
This is the official Python website and
it will detect the operating system and based on that it would recommend you to
download Python. Here I am using WINDOWS so it gave me the download options for
Python 2 and Python 3 . I would recommend you to download the latest
version of Python 3 .
Installation steps are pretty simple. You just have
to accept the agreement and finish the installation.
Note:
for Mac OS
If you are using Mac OS X then you may notice that
Python is already installed in your system,
however it would most likely be a Python 2 so you can download the latest
Python 3 version from here and install it in your system.
Install PyCharm Python IDE in
Windows, Mac OS X, Linux/Unix
In the previous we have seen the Python introduction and installation.
In this page, we will learn how to install PyCharm (a popular IDE for Python
programming).
PyCharm
Installation
1.
Go to this link: https://www.jetbrains.com/pycharm/download/ and
download the community edition. This type window you find
2. Install the downloaded file prefer to download community one .
Mac: Double
click the .dmg file and drag PyCharm to the Application Folder.
Windows: Double
click the .exe file and follow the installation steps for the default PyCharm
installation.
Launch PyCharm
Mac: Go to the Applications folder
and click on the PyCharm icon. Alternatively, you can drag the icon to your
dock to open the IDE quickly by clicking on the icon in dock.
Windows: If you have followed the default installation process then you can see the PyCharm icon on your desktop. If you don’t find the icon then go to the PyCharm folder – C:\Program Files (x86)\JetBrains\PyCharm 2017.1\bin (the path may be different for your system) and click on the PyCharm.exe file to launch the IDE
This type window you get after installing Pycharm click New
Project and run your programs.