My First Python Program

 

The Setup

Windows

Go to Download Section and download the latest source release and install it

Screenshot (2)

Linux

python 3.4 is installed on the stable release of Ubuntu 14.04 you can check it by typing in Terminal

$python --version

if not installed type this in Terminal

sudo apt-get install python3-minimal

Screenshot from 2015-06-26 18:32:58

Type the following text into a single file named myfirst_program.py. Python works best with files ending in .py

print "Wanna Play with python ?"
print "... Don't get scared,  man !"
print "Pyhton is Fuckin Fun :)"
print "lets Do it"

Run this program using terminal

$python myfirst_program.py

Welcome

Welcome to the interactive Python tutorial. Whether you are an experienced programmer or not, this blog is for everyone who wishes to learn the Python programming language.

Screenshot from 2014-11-21 22:53:41

5 Reasons why to Learn Python

Python is Efficient

A ton of mental energy these days is going into Big Data (both on defining it and on processing it). The more data you have to process, the more important it becomes to manage the memory you use.

Python provides generators, both as expressions and from functions.

For applications where you are dealing with even larger data sets, this sort of tool can be indespensible. David Beazley has a great slide deck online that provides some very compelling examples of using generators for system tasks. Take a look and see what sparks start flying in your imagination!

Generators allow for iterative processing of things, one item at a time. This doesn’t seem so fancy, until you start to realize that normal iterative processing of a list requires a list. A list takes memory. A really big list takes a lot of memory.

Generators allow for iterative processing of things, one item at a time. This doesn’t seem so fancy, until you start to realize that normal iterative processing of a list requires a list. A list takes memory. A really big list takes a lot of memory.

Where this becomes particularly handy is when you have a long chain of processes you need to apply to a set of data. Generators allow you to grab source data one item at a time, and pass each through the full processing chain.

I often face the problem of needing to migrate data from one website into another. Some of the sites I’m migrating have over a decade of history, gigabytes of content. Using the generator-based migration tool collective.transmogrifier I can read data from the old site, make complex, interdependent updates to the data as it is being processed, and then create and store objects in the new site all in constant memory.

Python is Fast

Okay, okay. I hear snorts out there. I mean, Python is an interpreted language, right? Aren’t they all slow?

The thing is that some amazing work has been done over the past years to improve Python’s performance.

The PyPy project aims to speed up Python as a whole (and is doing a great job of it).

Numba can offer amazing speedups simply by adding decorators to code you already have.

My point is that if you want to do high-performance computing, Python is a viable option today.

Python is Broad

Python has been around for quite some time now, and is used in nearly every field of endeavour. A reddit thread asked the question
how do you use Python at work and the answers show tasks ranging from systems automation, testing, and ETL to gaming, CGI and web development.

Disney uses Python
to help power their creative process.

Mozilla uses Python to explore their extensive code
base
and releases tons of open source packages
built in python.

Checking PyPi, the public package index for Python, shows 40 thousand add-ons available, across nearly 300 listed topic categories.

Basically, if you want to do something in Python, chances are pretty good someone else already has, and you don’t need to start from scratch.

Python is not Python

Recently, I was reading a post about why there are so many different Pythons.

The author’s point was that Python is not actually a language, it’s a
description of a language. What this means is that you can implement python in any number of ways.

The Python most people interact with is CPython, an implementation written in C. One of the features of CPython is that it offers clean integration with code that is written in C, so implementing wrappers around C libraries is relatively simple.

But there’s also Jython which offers deep integration with Java code, Iron Python to work with C# and .NET code, PyObjc to write
python code using ObjectiveC toolkits and even pyjs which offers to compile your python to JavaScript.

The point is that if you already have a software stack in one of these
languages, it’s pretty simple to incorporate Python into your working environment so you can benefit from its greatest power of all.

Python is Easy

Python has gained a reputation as being easy to learn. The syntax of the language is designed to be readable. There’s plenty of argument on the subject, but the facts speak
for themselves.

Much of Python’s popularity is in fields like scientific
computing
. The people working in this field are scientists first, and programmers second (if at all).

Advanced systems like NumPy and SciPy were started not by teams of software engineers, but by domain experts building the tools they needed to get a job done.