Learn Python Programming
Learn Python Programming
It has simple easy-to-use syntax, making it the perfect language for someone trying
to learn computer programming for the first time.
This is a comprehensive guide on how to get started in Python, why you should
learn it and how you can learn it. However, if you knowledge of other programming
languages and want to quickly get started with Python, visit Python tutorial page.
TABLE OF CONTENTS
Python Tutorials
About Python Programming
The syntax of the language is clean and length of the code is relatively short. It's fun
to work in Python because it allows you to think about the problem rather than
focusing on the syntax.
History of Python
Python is a fairly old language created by Guido Van Rossum. The design began in
the late 1980s and was first released in February 1991.
Python 3.0 (Emphasis on removing duplicative constructs and module) December 3, 2008
Python 3.5 (Last updated version) September 13, 2015
3. Portability
You can move Python programs from one platform to another, and run
it without any changes.
It runs seamlessly on almost all platforms including Windows, Mac OS
X and Linux.
7. Object-oriented
Everything in Python is an object. Object oriented programming (OOP)
helps you solve a complex problem intuitively.
With OOP, you are able to divide these complex problems into smaller
sets by creating objects.
Applications of Python
Web Applications
You can create scalable Web Apps using frameworks and CMS (Content
Management System) that are built on Python. Some of the popular platforms for
creating Web Apps are: Django, Flask, Pyramid, Plone, Django CMS.
Sites like Mozilla, Reddit, Instagram and PBS are written in Python.
There are numerous libraries available in Python for scientific and numeric
computing. There are libraries like: SciPy and NumPy that are used in general
purpose computing. And, there are specific libraries like: EarthPy for earth science,
AstroPy for Astronomy and so on.
Also, the language is heavily used in machine learning, data mining and deep
learning.
Python is slow compared to compiled languages like C++ and Java. It might not be a
good choice if resources are limited and efficiency is a must.
However, Python is a great language for creating prototypes. For example: You can
use Pygame (library for creating games) to create your game's prototype first. If you
like the prototype, you can use language like C++ to create the actual game.
It is a good language with a lot of features and capabilities. Yet, it's one of the
easiest language to learn because of its simple easy-to-use syntax.
2. a = 2
3. b = 3
4. sum = a + b
print(sum)
Even if you have never programmed before, you can easily guess that
this program adds two numbers and prints it.
5. Not overly strict
You don't need to define the type of a variable in Python. Also, it's not
necessary to add semicolon at the end of the statement.
You will find the easiest way to run Python on your computer (Windows, Mac OS X
or Linux) in this section.
4. The installation process is straight forward. Run the Sublime Text Disk
Image file you downloaded and follow the instructions.
6. Write the code and save it again. For starters, you can copy the code
below:
print("Hello, World!")
$ cd Python-3.6.0
7. $ ./configure
8. $ make
9. $ make install
15.Write the code and save it (Ctrl+S or File > Save) . For starters, you
can copy the code below:
print("Hello, World!")
2. When the download is completed, double-click the file and follow the
instructions to install it.
When Python is installed, a program called IDLE is also installed along
with it. It provides graphical user interface to work with Python.
3. Open IDLE, copy the following code below and press enter.
4. print("Hello, World!")
6. Write Python code (you can copy the code below for now) and save
(Shortcut: Ctrl+S) with .py file extension like: hello.py or your-first-
program.py
print("Hello, World!")
7. Go to Run > Run module (Shortcut: F5) and you can see the output.
Congratulations, you've successfully run your first Python program.
Your First Python Program
However, Python is one of the easiest language to learn, and creating "Hello,
World!" program is as simple as writing print("Hello, World!"). So, we are going to
write a different program.
1
2
3
4
5
# Add two numbers
num1 = 3
num2 = 5
sum = num1+num2
print(sum)
Run
Powered by DataCamp
Comments are used in programming to describe the purpose of the code. This helps
you as well as other programmers to understand the intent of the code. Comments
are completely ignored by compilers and interpreters.
Line 2: num1 = 3
Here, num1 is a variable. You can store a value in a variable. Here, 3 is stored in this
variable.
Line 3: num2 = 5
Line 5: print(sum)
The print() function prints the output to the screen. In our case, it prints 8 on the
screen.
im_a_parent:
im_a_child:
im_a_grand_child
im_another_child:
im_another_grand_child
Final Words
Python is a terrific language. The syntax is simple and code length is short which
makes is easy to understand and write.
If you are getting started in programming, Python is an awesome choice. You will be
amazed how much you can do in Python once you know the basics.
It's easy to overlook the fact that Python is a powerful language. Not only is it good
for learning programming, it's also a good language to have in your arsenal. Change
your idea into a prototype or create games or get started with data Science, Python
can help you in everything to get started.