What is Python?

The Python Software Foundation describes Python as a programming language that lets you work quickly and integrate systems more effectively.

The creator of Python, Van Rossum stated in 1996: Over six years ago, in December 1989, I was looking for a "hobby" programming project that would keep me occupied during the week around Christmas. My office ... would be closed, but I had a home computer, and not much else on my hands. I decided to write an interpreter for the new scripting language I had been thinking about lately: a descendant of ABC that would appeal to Unix/C hackers. I chose Python as a working title for the project, being in a slightly irreverent mood (and a big fan of Monty Python's Flying Circus).

This is how Python came to existence! It is one of the most widely used Programming languages in this age and can be used for almost any Programming related task. Python has also become important to learn these days because of it's use in Data Science. Words like Big Data, Machine Learning, Artificial Intelligence are doing rounds, and if you wish to go learn that, this is a very good place to be!

To illustrate the power of Python, here is an example. Lets say we have a favorite website, namely 9GAG. Well, who doesn't love them anyways? They usually have a lot of different sections available and it gets difficult to choose the ones we might want to watch. This is mostly due to the compactness and content on the website. What if we write a code to receive all the links of pages 9GAG has, and then decide the ones we wish to visit from that list? Here is the code:

import httplib2
from BeautifulSoup import BeautifulSoup, SoupStrainer

http = httplib2.Http()
status, response = http.request('http://www.9gag.com')

for link in BeautifulSoup(response, parseOnlyThese=SoupStrainer('a')):
    if link.has_key('href'):
        print link['href']

You can simply input the code in a Python interpretor and see the magic happen!

TIP Before running it on a Python interpretor, remember to do pip install beautifulsoup and pip install httplib2 through your Command prompt or Command shell.

The output would be:

https://9gag.com/settings
https://9gag.com
https://9gag.com/hot
https://9gag.com/trending
https://9gag.com/fresh
javascript:void(0);
http://9gag.tv?ref=9nav
http://9gag.com/nsfw
http://9gag.com/gif?ref=9nav
http://9gag.com/wtf?ref=9nav
http://9gag.com/gaming
https://notsafeforwork.com?ref=9nav
http://9gag.com/mobile?ref=9nav
https://9gag.com/video?ref=nav
https://9gag.com/got?ref=fb9nav
http://9gag.com/school?ref=9nav
https://9gag.com/iphone
https://9gag.com/android
https://9gag.com/funny
https://9gag.com/video
https://9gag.com/ask9gag
https://9gag.com/gaming
https://9gag.com/wtf
https://9gag.com/savage
https://9gag.com/gif
https://9gag.com/movie-tv
https://9gag.com/superhero
https://9gag.com/comic
https://9gag.com/sport
https://9gag.com/girly
https://9gag.com/relationship
https://9gag.com/awesome
https://9gag.com/cute
https://9gag.com/country
https://9gag.com/school
https://9gag.com/horror
https://9gag.com/science
https://9gag.com/imadedis
https://9gag.com/politics
https://9gag.com/timely
https://9gag.com/girl
https://9gag.com/anime-manga
https://9gag.com/food
https://9gag.com/darkhumor
https://9gag.com/nsfw
https://9gag.com/got
https://9gag.com/overwatch
https://9gag.com/advertise
https://9gag.com/rules
https://9gag.com/tips
https://9gag.com/faq
https://9gag.com/tos
https://9gag.com/privacy
https://9gag.com/jobs
https://9gag.com/contact
javascript:void(0)
https://9gag.com/login
https://9gag.com/signup
javascript:void(0);
javascript:void(0);
javascript:void(0);
https://9gag.com/notifications
javascript:void(0)
https://9gag.com/settings
https://9gag.com/logout
https://9gag.com/tag/game-of-thrones?ref=featured-tag
https://9gag.com/tag/death-note?ref=featured-tag
https://9gag.com/tag/rick-and-morty?ref=featured-tag
https://9gag.com/tag/disloyal-man?ref=featured-tag
https://9gag.com/tag/beam?ref=featured-tag
https://9gag.com/tag/back-to-school?ref=featured-tag
https://9gag.com/tag/pc-master-race?ref=featured-tag
https://9gag.com/tag/programmers-know?ref=featured-tag
https://9gag.com/tag/office-survival?ref=featured-tag
https://9gag.com/tag/tinder?ref=featured-tag
https://9gag.com/tag/kermit-the-frog?ref=featured-tag
https://9gag.com/tag/i-drink-beer?ref=featured-tag
https://9gag.com/tag/dankmemes?ref=featured-tag
https://9gag.com/tag/satisfying?ref=featured-tag
https://9gag.com/tag/rare-doggos?ref=featured-tag
https://9gag.com/tag/harry-potter?ref=featured-tag
https://9gag.com/tag/parenting?ref=featured-tag
https://9gag.com/tag/video?ref=featured-tag
https://9gag.com/tag/puns?ref=featured-tag
https://9gag.com/tag/cosplay?ref=featured-tag

If you read through them carefully, it will start to make sense. All the links available to browse for today are available! It changes everyday so it will be different when you launch it on your system.

There might be a question here, what is a Python interpretor? Well, it is a system or "box" that understands code in Python and follows the instructions. You will have a full understanding of what we just did in the coming weeks. For now, enjoy the convenience of Python!

The Zen of Python

The Zen of Python is a collection of 20 software principles that influence the design of Python programming language.

You can simply type import this and click enter on any Python interpreter to read it.

To simplify this for MAC users, go to Terminal, and enter $ python. Once inside the python interpreter, type import this.

For Windows users, use the command prompt and enter > python. Once inside the python interpreter, type import this.

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one—and preferably only one—obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than right now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea—let's do more of those!

This might confuse you a bit, so refer to this page for a much detailed explanation of this poem.

results matching ""

    No results matching ""