Posted in Python

Python Post #7 Important pointers (´・ω・)っ由


(✿ ♥‿♥)

As many of you by now may know, Python is a commonly used high-level programming language. The core benefit of python is to boost code readability, whereby the program’s language arrangement allows coders to write concepts in fewer lines of codes as compared to other programming languages such as Java. Python language has constructs that deliver clear and concise programs for both small and big developer projects. Python supports various programming forms, including object orientation, imperative styles, and functional programming styles.
Now moving on from the basic concepts, here are some simply useful and, well you might say essential, tips for the awakened programmers like you…
1) Writing functions with its variable lists
One of the awesome things about Python is with its variable parameter lists. Programmers can simply write functions without even knowing what sort of parameters will be passed.
Let’s focus on the codes listed below the asterisk at the first marks parameter may be any positional parameters.
def lessThan(cutoffMark, *marks) :
”’ Return a list of values less than the cutoff. ”’
    arr = []
    for val in marks :
        if val < cutoffMark:
            arr.append(val)
    return arr
After using the function, we get:
>>> print(lessThan(10, 2, 17, -3, 42))
[2, -3]
Looking at the first positional value we state in the function call (10) that is given to the first parameter in the function (cutoffMark), it will cause all the remaining positional values to be assigned to marks. Scanning through these values, we can then search for those that are smaller than the cutoff value.
2) Apply the same technique used in tip 1 with named parameters
Likewise with named parameters, as shown below, a double asterisk place at the dict parameter below means any named parameters. Python will then be able to provide us with value pairs in dictionary form.
def printVals(prefix=”, **dict):
#Print out the extra named parameters and their values
    for key, val in dict.items():
        print(‘%s [%s] => [%s]’ % (prefix, str(key),str(val)))
After using the function, we get:
>>> printVals(prefix=’..’, foo=42, bar=’!!!’)
[foo] => [42]
[bar] => [!!!]
>>> printVals(prefix=’..’, one=1, two=2)
[two] => [2]
[one] => [1]
Note*
As extra named parameters are passed through in a dictionary, which is an unordered data structure, the values are not printed out in the same order as they were not defined in the function call.
3) Using True and False as Indexes
A technique you can use to select values is to use True and False as list indexes. The technique is useful due to the fact that False == 0 and True == 1:
test = True
# test = False
result = [‘Test is False’,’Test is True’][test]
# result is now ‘Test is True’
This method is simple and you wouldn’t encounter any hiccups when the value_if_true must actually be true.
However, do bear in mind that this method only works when you know the test is False or True (0 or 1), but not other integer values or arbitrary objects.
4) Improving Python performance with multiple approaches
If you intend on placing similar coding approaches whenever you create an application, it could cause your application to run slower than before. For instance, when handling codes in a dictionary, you may adopt a secured approach of dictating whether an item exists and update it or you can choose an alternative option by adding the item directly and then handling the given circumstances where the item does not exist as an exception.
Focusing on the safe and secured approach first,
p = 16
myDiction = {}
for i in range(0, p):
    char = ‘abcd'[i%4]
    if char not in myDict:
        myDiction[char] = 0
myDiction[char] += 1
print(myDiction)
As predicted, the code will normally perform quicker when myDict is empty at the beginning. However, when myDict is filled or almost filled with data, the alternative option is proven to be better as based on the set of codes listed below.
p = 16
myDiction = {}
for I in range(0, p):
    char = ‘abcd'[i%4]
    try:
        myDiction[char] += 1
    except KeyError:
        myDiction[char] = 1
print(myDiction)

Based on the 2 coding examples listed above, the output of {‘d’: 4, ‘c’: 4, ‘b’: 4, ‘a’: 4} is similar. However, the only difference is the manner in which output is obtained. That being said, it’s certainly helpful for programmers to take the unconventional approach to boost your python’s performance speed.
5) Remember to optimize your loops
One of the beautiful things when working with Python is that you can depend on plenty of different techniques for making loops run faster. However, one crucial reminder while optimizing loops is that you have to prevent yourself from using dots within a loop. For instance, let’s focus on the series of codes listed below:
lowerlist = [‘this’, ‘is’, ‘lowercase’]
upper = str.upper
upperlist = []
append = upperlist.append
for word in lowerlist:
    append(upper(word))
print(upperlist)
#Output = [‘THIS’, ‘IS’, ‘LOWERCASE’]
Whenever you need to make a call to str.upper, Python assesses the technique. On the other hand, if you place such an evaluation in a variable, the value will be known and Python can perform the tasks quicker than before. The fact of the matter is that you should lessen the amount of work that Python performs within loops as the Python software can probably slow things down based on that example.
Of course, there are other ways to optimize loops such as using list comprehensions, which could be argued to be the next best alternative in achieving faster loops.
6) Useful tip to check whether a file exists in Python
With python, there are several ways you can use to see whether a file does exist (and is accessible) from a directory. One way is by using the os.path.isfile path. This function will be true if the given path is a prevailing, ordinary file. The file adopts symbolic links, which makes foros.path.islink(path) to be true and os.path.isfile(path) to also be true. The os.path.isfile is a very practical one-liner function that helps to check if a file exists.
7) Mixing Python and shell scripts 
It could be useful for you to write a script that can function as a shell script or as a Python script at the exact time, which is probable. To do it, the sequence of four quote characters requires an empty string to the shell, but in Python, it begins as a triple-quoted string that has a quote character. So you can embed shell commands within the python triple-quoted string. Take note that the first string in a module or script can be simply stored as the doc string for that module, but besides that the Python interpreter will just ignore it.
The below example display this particular trick.
#!/bin/sh
“”””:
if which python >/dev/null; then
    exec python “$0” “$@”
else
    echo “${0##*/}: Python not found. Please install Python.” >&2
exit 1
fi
“””
__doc__ = “””
Demonstrate how to mix Python + shell script.
“””
import sys
print “Hello World!”
print “This is Python”, sys.version
print “This is my argument vector:”, sys.argv
print “This is my doc string:”, __doc__
sys.exit (0)
8) Know how to translate signal numbers to names
As of now, there is no existing function in the “signal” module that allows programmers to be able to change a signal number to a signal name. However, the listed example below could be a handy function for you to use.
def signal_numtoname (num):
name = []
for key in signal.__dict__.keys():
    if key.startswith(“SIG”) and getattr(signal, key) == num:
        name.append (key)
    if len(name) == 1:
        return name[0]
    else:
        return str(num)
9) Using a member of set type
You may not know, but there have been concepts that can boil down to operations on a set. Need to ensure that your list does not have duplicates? Or looking to see whether your two lists have anything common? Python does have a set function that allows you to make these operations quick and easy to read.
Also, you can use the intersection function to compare all the items. After which, you will be able to return them once the items have both sets in common.
# deduplicate a list *fast*
print(set([“chicken”, “eggs”, “bacon”, ” chicken “]))
# {‘bacon’, ‘eggs’, chicken }
# compare lists to find differences/similarities
# {} without “key”:”value” pairs makes a set
menu = {“pancakes”, ” chicken “, “eggs”, “bacon”}
new_menu = {“coffee”, ” chicken “, “eggs”, “bacon”, “bagels”}
new_items = new_menu.difference(menu)
print(“Try our new”, “, “.join(new_items))
# Try our new bagels, coffee
discontinued_items = menu.difference(new_menu)
print(“Sorry, we no longer have”, “, “.join(discontinued_items))
# Sorry, we no longer have pancakes
old_items = new_menu.intersection(menu)
print(“Or get the same old”, “, “.join(old_items))
# Or get the same old eggs, bacon, chicken
full_menu = new_menu.union(menu)
print(“At one time or another, we’ve served:”, “, “.join(full_menu))
# At one time or another, we’ve served: coffee, chicken, pancakes, bagels, bacon, eggs
10) Setting up Virtualenv in python
As virtualenv is a very important function for sandboxing Python environments, as it allows you to form independent Python contexts that are similar to separate sandboxes. Which is definitely a better than modifying the global python environment?
One of the key benefits of sandboxing your Python environment is that you can easily test your code under different Python versions and package dependencies.
To install virtualenv, you need to set up pip first. As such follow these commands:
# easy_install is the default package manager in CPython
% easy_install pip
# Install virtualenv using pip
% pip install virtualenv
% virtualenv python-workspace
# create a virtual environment under the folder ‘python-workspace’
With the new virtualenv set up under ‘python-workspace’, you have to activate the Python environment in order for the current shell to move into the virtualenv:
% cd python-workspace
% source ./bin/activate # activate the virtualenv ‘python-workspace’
% python # enter an interpreter shell by executing the current virtual python program under ‘python-workspace/bin/python’

So that being said, and assuming that I have mentioned everything necessary,let me disclose the winner of today’s lot picking…

.

.

And the lucky winner is …


Java



ᕦ(ò_óˇ)ᕤ
I hope I can deliver this a little less messier than Python *sigh…

φ(゚ ω゚//)♠


Posted in Python

Python Post #6 Python One Liners ᕕ( ᐛ )ᕗ ✎✐✎✐✎✐✎✐✎✐✎✐

(ღ˘⌣˘ღ)

Performing one-liners directly on the Command Prompt can be accomplished by using Python’s -cmd flag (-c for short), and typically requires the import of one or more modules. 

(눈_눈;)

How to Write One-liners in Python?

One-Liners are hard to comprehend, especially in Python. Given a sample one can come up with their own One Liner. Though they are not recommended while actual coding… It is pretty fun to condense normal code to utter gibberish and make the system.. Well I don’t know…Hang maybe
。(*^▽^*)ゞ

So assuming that you are familiar with the basics of Python and the changes made from Python 2 and Python 3… The only stable versions I am aware of…Let me dive to Pointers on One Liners in Python…

(*•̀ᴗ•́*)و ̑̑

  • So first thing first…As we all know that Python is considered a lazy language…And for a Good Reason too! The blocks of code are distinguished by indentation and not braces,This kinda makes it hard to Create one liners with multiple loops and functions…So let’s stick with a Single never ending for loop 

while 1:…*Gibberish*…

  • And then we have this concept of Recursive function…A Function call inside a function…A pretty convenient thing considering my goal here…Use lambda functions…Since they are preferable than having an actual function definition inside a infinite loop… 
  • And OFC…How can I forget one of my favorite modules…import random…try and read the documentation of this module …since that was where I got most of these one liners 

random.choice(“set of characters to choose from”)


random.randint(lowerBound,upperBound) 

So here are a few… assuming that by now you have installed either a Python2 or Python3 .. Copy these and paste in the Command Prompt 

Python2

python -c “while 1:import random;print random.choice(‘|-_+=\\/’), ”

python -c “while 1: locals().setdefault(‘i’,60); import time,random; print(‘ ‘*i+”+’ ‘*(80-i-1)+’|’);time.sleep(.2); i+=random.randint(-2,2)”

python -c “while 1:import random;print “random.randint(0,100)”, map(lambda n:(lambda f:f(f,n))(lambda f,n:{True:lambda:1, False:lambda:n*f(f,n-1)}[n<=1]()),range(0,20))"

python -c “import random,time; p=lambda:random.choice(‘♥♦♣♠’);[print ‘[{}|{}|{}]’.format(p(),p(),p(),t=time.sleep(.2)), for i in range (20)]”

Python3

python -c “while 1: locals().setdefault(‘i’,60); import time,random; print(‘ ‘*i+”+’ ‘*(80-i-1)+’|’); time.sleep(.1); i+=random.randint(-2,2)”

python -c “import random,time; p=lambda:random.choice(‘♥♦♣♠’);[print(‘[{}|{}|{}]’ .format(p(),p(),p(),t=time.sleep(.1)),end= ‘\r’) for i in range (20)]”

python -c “import random;n=random.randint(1,99); [(lambda a:print(‘Y’ if a==n else ‘H’ if a>n else ‘L’))(int(input())) for i in range(6)]”

python -c “while 1:import random; print(random.choice(‘|-_+=\\/’), end=”)”



φ(*⌒▽⌒)ノ



Posted in Python

Python Post #5 Python Mini Project Source Codes (づ。◕‿‿◕。)づ

ԅ[ •́ ﹏├┬┴┬┴


(−_−;)

Well if you were like me and Python is your first language then you would most probably be able relate to this …

You are trying to learn programming and many people suggested to learn Python as the first language. You take their advice, you download Python and get all set up. Maybe you take a tutorial or two in order to learn some basic syntax… Now you are sitting in front of your computer and you are wondering what to do next. I suggest you start on some projects and get programming to learn more Python. I have compiled a few available projects myself… and will include the source code in this post.

Refrain from looking at the source code, even when your stuck. If you get to the point where you have nowhere else to look, take a tiny peak but then go straight back and start doing your work again. If your programs works and our source code doesn’t match, pat yourself on the back! Then look at my source code versus yours and see how you can shorten and make your programs better or if you feel that you came up with a better solution let me know of it.

My way of doing it, is probably not the best way,so go on and explore and  experiment!

✧٩(•́⌄•́๑)و ✧


┬┴┬┴┤(・‿├┬┴┬┴


Posted in Python

Python Post #4 Python OpenCV (≖͞_≖̥)

….φ(︶▽︶)φ…

(ღ˘⌣˘ღ)


So then, as mentioned earlier there are various possibilities in Python and it is just a library away! In this post, I will let you know how to install a randomly selected library and then go about on the basis of its functionalities … Maybe 
*Fingers Crossed*
.
.
.
Okay so the winner of today’s lot picking is 
.
.
.


OpenCV… Well, it could be worse (in the sense, not much to discuss on !)…

Okay , so before going about OpenCV basics along with its installation, let me give a basic overview on OpenCV …
OpenCV-Python

OpenCV-Python is a library of Python bindings designed to solve computer vision problems.
Python is a general purpose programming language started by Guido van Rossum that became very popular very quickly, mainly because of its simplicity and code readability. It enables the programmer to express ideas in fewer lines of code without reducing readability.
Compared to languages like C/C++, Python is slower. That said, Python can be easily extended with C/C++, which allows us to write computationally intensive code in C/C++ and create Python wrappers that can be used as Python modules. This gives us two advantages: first, the code is as fast as the original C/C++ code (since it is the actual C++ code working in the background) and second, it easier to code in Python than C/C++. OpenCV-Python is a Python wrapper for the original OpenCV C++ implementation.
OpenCV-Python makes use of Numpy, which is a highly optimized library for numerical operations . All the OpenCV array structures are converted to and from Numpy arrays. This also makes it easier to integrate with other libraries that use Numpy such as SciPy .
To Install:
Depending on your version of Python Download and the type of computer you use these are the corresponding downloads, Hopefully, they work properly…

(ノ^◡^)ノ︵ ʌɔuǝdo
PS. If you are as confused as I was when I first went around figuring out how to go about fixing the numerous bugs that just rose exponentially when I tried to rectify some others, well  trust me when I say this , Its easier to uninstall everything and start it from scratch. This would include uninstalling all Python related .msi or .exe file installations that you can find in your control panel, and installing the fool proof module list which I will provide shortly,and change the path settings(refer the previous Blogpost please.)

If there is anyone with other OS,I am sorry for not being considerate , If you tell me about it,maybe , I might help you.And if any of the links are nonfunctional please let me know.

If everything is functional, it will import cv2 module, otherwise, an error message will be shown.

.
.
.

Iff the above setup is done you can proceed further and be sure to understand what I have shared.

┬┴┬┴┤(・‿├┬┴┬┴

Posted in Python

Python Post #3 Python PyGame Ψ( ●`▽´● )Ψ

\\\ ٩(๑❛ワ❛๑)و ////

So far, all of our codes have only used text. The text is displayed on the screen as output and the user types in text from the keyboard as input. This is simple, and an easy way to learn to program. But from this post onward, plain text output won’t be the case. This post might teach you how to use the Pygame library to make games with graphics, animation, and sound.
In these posts, we’ll find the source code for simple programs that are not games but demonstrate the Pygame concepts I have tried to convey. Links to my drive will present the source code for a complete Pygame game using all the concepts you should have learned by then.
I should have mentioned this earlier…A software library is a code that is not meant to be run by itself but included in other programs to add new features. By using a library a programmer doesn’t have to write the entire program, but can make use of the work that another programmer has done before them.

Pygame is a software library that has modules for graphics, sound, and other features that games commonly use.

Okay so that being said , I am just gonna dive into the concepts,cause I am like super drained ,so yeah…,I hope you don’t feel like this is a compilation of some leaked out notes of a Mad Scientist.

彡(-_-;)彡

Installing Pygame


Pygame does not come with Python. But like Python, Pygame is available for free. You will have to download and install Pygame, which is as easy as downloading and installing the Python interpreter,which you might have already done, assuming you have read the previous posts with sincerity and devotion .
I am gonna assume that you have the Windows operating system, but Pygame works the same for every operating system. You need to download the Pygame installer for your operating system and the version of Python you have installed (2.7). For Windows, download the msi file. (This is Pygame for Python 2.7 on Windows. If you installed a different version of Python (such as 2.5 or 2.4) download the .msi file for your version of Python.)

ps: I recommend downloading 2.7 pythons since it is the most (as far as I know) stable and has stable and legal versions of the libraries I had specified earlier.In case you have already downloaded a higher version and have gotten an error,I might not be able to help you.But if you do feel like negating my statement do comment your wishes or mail me or just ignore the following .
The current version of Pygame is 1.9.2. But if you see a newer version on the website, download and install the newer Pygame. For Mac OS X and Linux, follow the directions on the download page for installation instructions.
On Windows, double-click on the downloaded file to install Pygame. To check that Pygame is install correctly, type the following into the IDLE:
>>> import pygame
If nothing appears after you hit the Enter key, then you know Pygame has successfully been installed. 
If the error ImportError: No module named pygame appears, then try to install Pygame again (and make sure you typed import pygame correctly).

Check your paths right click on Computer(icon) got to Properties and click on Advanced system settings.Go to environmental variables.Update the following paths.
#Case sensitive #

Variable    Value
Path   ;C:\Python27(remove the previous version of python and  do this i.e.. change 34 to 27)
PYTHONHOME C:\Python27
PYTHONPATH    C:\Python27

*Hope this helps you… let me know if it is otherwise*

Okay, so, this time, I will put a link here to my drive that has five small programs that demonstrate how to use the different features that Pygame provides. In one of them, you will use these features for a complete game written in Python with Pygame.
A video tutorial of how to install Pygame is available .

Go to Folder in Drive!

ԅ(≖‿≖ ;ԅ)
Posted in Python

Python Post #2 Python Additional Features (☆^_^☆)

┬┴┬┴┤ ͜ʖ ͡°) ├┬┴┬┴

I hope that you can understand the flow of the above function. If not please go to the previous post and read through the .py file that I have shared …
Okay then,just to recap ,I have tried to make sure to put as much python programming concepts in one executable file.I hope it was useful for whatever you were doing!
The file, if it had been studied with as much effort as was applied in the making,then you should be familiar with

  • Python variables
  • Conditionals
  • Class
  • File handling
  • Exception handling

(PS:I randomly update since I am not very comfortable with my incoherent .py files )

-(๑☆‿ ☆#)ᕗ

Now that we are familiar with the basic syntax of Python,we can now dive into a bunch of special libraries that have been a part of my toolbelt and should be a part of yours as well. So here they are:
1. Requests. The most famous http library written by kenneth reitz. It’s a must have for every python developer.
2. Scrapy. If you are involved in webscraping then this is a must have library for you. After using this library you won’t use any other.
3. wxPython. A GUI toolkit for python. I have primarily used it in place of tkinter. You will really love it.
4. OpenCV. OpenCV (Open Source Computer Vision Library) is an open source computer vision and machine learning software library. It’s an image processing library for machines,like the eyes of an automated machine.
5. SQLAlchemy. A database library. Many love it and many hate it. The choice is yours.
6. BeautifulSoup. I know it’s slow but this xml and html parsing library is very useful for beginners.
7. Twisted. The most important tool for any network application developer. It has a very beautiful api and is used by a lot of famous python developers.
8. NumPy. How can we leave this very important library ? It provides some advance math functionalities to python.
9. SciPy. When we talk about NumPy then we have to talk about scipy. It is a library of algorithms and mathematical tools for python and has caused many scientists to switch from ruby to python.
10. matplotlib. A numerical plotting library. It is very useful for any data scientist or any data analyzer.
11. Pygame. Which developer does not like to play games and develop them ? This library will help you achieve your goal of 2d game development.
12. Scapy. A packet sniffer and analyzer for python made in python.
13. nltk. Natural Language Toolkit – I realize most people won’t be using this one, but it’s generic enough. It is a very useful library if you want to manipulate strings. But it’s capacity is beyond that. Do check it out.
14. nose. A testing framework for python. It is used by millions of python developers. It is a must have if you do test driven development.
15. SymPy. SymPy can do algebraic evaluation, differentiation, expansion, complex numbers, etc. It is contained in a pure Python distribution.
16. IPython. I just can’t stress enough how useful this tool is. It is a python prompt on steroids. It has completion, history, shell capabilities, and a lot more. Make sure that you take a look at it.


φ(*⌒▽⌒)ノ



Posted in Python

Bonus – Why Python? °˖✧◝(⁰▿⁰)◜✧˖°

(◕‿◕✿)

If you are new to Python programming or in computer programming in general, it would certainly be important for you to get some information on the advantages and disadvantages of the language and understand why would somebody want to use it. In this post, I will not enter into the technical details of the language nor use fancy words to describe you some of the language specifics. My intention is to give you some simple insight so that you can decide for yourself whether or not it would be a good idea for you to choose Python as your main programming language!

Features of Python
Simple
Python is a simple and minimalistic language. Reading a good Python program feels almost like reading English, although very strict English! This pseudo-code nature of Python is one of its greatest strengths. It allows you to concentrate on the solution to the problem rather than the language itself.

Easy to Learn
As you will see, Python is extremely easy to get started with. Python has an extraordinarily simple syntax, as already mentioned.

Free and Open Source
Python is an example of a FLOSS (Free/Libré and Open Source Software). In simple terms, you can freely distribute copies of this software, read it’s source code, make changes to it, use pieces of it in new free programs, and that you know you can do these things. FLOSS is based on the concept of a community which shares knowledge. This is one of the reasons why Python is so good – it has been created and is constantly improved by a community who just want to see a better Python.

High-level Language
When you write programs in Python, you never need to bother about the low-level details such as managing the memory used by your program, etc.

Portable
Due to its open-source nature, Python has been ported (i.e. changed to make it work on) to many platforms. All your Python programs can work on any of these platforms without requiring any changes at all if you are careful enough to avoid any system-dependent features. You can use Python on Linux, Windows, FreeBSD, Macintosh, Solaris, OS/2, Amiga, AROS, AS/400, BeOS, OS/390, z/OS, Palm OS, QNX, VMS, Psion, Acorn RISC OS, VxWorks, PlayStation, Sharp Zaurus, Windows CE and even PocketPC !

Interpreted
This requires a bit of explanation.
A program written in a compiled language like C or C++ is converted from the source language i.e. C or C++ into a language that is spoken by your computer (binary code i.e. 0s and 1s) using a compiler with various flags and options. When you run the program, the linker/loader software copies the program from hard disk to memory and starts running it.
Python, on the other hand, does not need compilation to binary. You just run the program directly from the source code. Internally, Python converts the source code into an intermediate form called bytecodes and then translates this into the native language of your computer and then runs it. All this, actually, makes using Python much easier since you don’t have to worry about compiling the program, making sure that the proper libraries are linked and loaded, etc, etc. This also makes your Python programs much more portable, since you can just copy your Python program onto another computer and it just works!

Object Oriented
Python supports procedure-oriented programming as well as object-oriented programming. In procedure-oriented languages, the program is built around procedures or functions which are nothing but reusable pieces of programs. In object-oriented languages, the program is built around objects which combine data and functionality. Python has a very powerful but simplistic way of doing OOP, especially when compared to big languages like C++ or Java.

Extensible
If you need a critical piece of code to run very fast or want to have some piece of algorithm not to be open, you can code that part of your program in C or C++ and then use them from your Python program.

Embeddable
You can embed Python within your C/C++ programs to give ‘scripting’ capabilities for your program’s users.

Extensive Libraries
The Python Standard Library is huge indeed. It can help you do various things involving regular expressions, documentation generation, unit testing, threading, databases, web browsers, CGI, ftp, email, XML, XML-RPC, HTML, WAV files, cryptography, GUI (graphical user interfaces), Tk, and other system-dependent stuff. Remember, all this is always available wherever Python is installed. This is called the ‘Batteries Included’ philosophy of Python. Besides, the standard library, there are various other high-quality libraries such as wxPython, Twisted, Python Imaging Library,PyGame and many more.

Summary
Python is indeed an exciting and powerful language. It has the right combination of performance and features that make writing programs in Python both fun and easy.

.
.
.

Until next time then…

┬┴┬┴┤(・‿├┬┴┬┴

Posted in Python

Python Post #1 Basics of Python ೭੧(❛▿❛✿)੭೨

┬┴┬┴┤ ͜ʖ ͡°) ├┬┴┬┴

(ノ◕ヮ◕)ノ *:・゚✧✧゚・: * ヽ(◕ヮ◕ヽ)

Quick! Which programming language will get you up and running writing applications on every popular platform around?


( ͡° ͜ʖ ͡°)

Give up? No?


Yes, it’s Python.

The amazing thing about Python is that you really can write an application on one platform and use it on every other platform that you need to support.

Unlike the other programming languages that promised to provide platform independence, Python really does make that independence possible.

Python emphasises code readability and a concise syntax that lets you write applications using fewer lines of code than other programming languages require.

In addition, because of the way Python works, you find it used in all sorts of fields that are filled with non-programmers. Some people view Python as a scripted language, but it really is so much more.

This post is all about getting up and running with Python quickly. You want to learn the language fast so that you can become productive in using it to perform your real job, which could be anything.

Unlike most, on the topic, this one starts you right at the beginning by showing you what makes Python different from other languages and how it can help you perform useful work in a job other than programming. You even get help with installing Python on your particular system.


Okay then, Let’s get down to business…


(ó ì_í)=óò=(ì_í ò)

Many programming languages are available today. In fact, a student can spend an entire semester in college studying computer languages and still not hear about them all. (I have done just that during my college days.)

ಠ_ಥ

You’d think that programmers would be happy with all these programming languages and just choose one to talk to the computer, but they keep inventing more. Programmers keep creating new languages for good reason.



(─‿‿─)

Each language has something special to offer — something it does exceptionally well. In addition, as computer technology evolves, so do the programming languages in order to keep up. Because creating an application is all about efficient communication, many programmers know multiple programming languages so that they can choose just the right language for a particular task. One language might work better to obtain data from a database, and another might create user interface elements especially well.

As with every other programming language, Python does some things exceptionally well, and you need to know what they are before you begin using it.

You might be amazed by the really cool things you can do with Python.Knowing a programming language’s strengths and weaknesses helps you use it better as well as avoid frustration by not using the language for things it doesn’t do well. The following sections help you make these sorts of decisions about Python.


Less application development time:

Python code is usually 2–10 times shorter than comparable code written in languages like C/C++ and Java, which means that you spend less time writing your application and more time using it.

Ease of reading:

A programming language is like any other language — you need to be able to read it to understand what it does. Python code tends to be easier to read than the code written in other languages, which means you spend less time interpreting it and more time making essential changes.

Reduced learning time:


The creators of Python wanted to make a programming language with fewer odd rules that make the language hard to learn. After all, programmers want to create applications, not learn obscure and difficult languages.

Creating rough application examples:


Developers often need to create a prototype, a rough example of an application, before getting the resources to create the actual application. Python emphasises productivity, so you can use it to create prototypes of an application quickly.

Scripting browser-based applications:

Even though JavaScript is probably the most popular language used for browser-based application scripting, Python is a close second. Python offers functionality that JavaScript doesn’t provide and its high efficiency makes it possible to create browser-based applications faster (a real plus in today’s fast-paced world).

Designing mathematical, scientific, and engineering applications:


Interestingly enough, Python provides access to some really cool libraries that make it easier to create math, scientific, and engineering applications. The two most popular libraries are NumPyand SciPy . These libraries greatly reduce the time you spend writing specialised code to perform common math, scientific, and engineering tasks.

Working with XML:

The eXtensible Markup Language (XML) is the basis of most data storage needs on the Internet and many desktop applications today. Unlike most languages, where XML is just sort of bolted on, Python makes it a first-class citizen. If you need to work with a Web service, the main method for exchanging information on the Internet (or any other XML-intensive application), Python is a great choice.

Interacting with databases:

Business relies heavily on databases. Python isn’t quite a query language, like the Structure Query Language (SQL) or Language INtegrated Query (LINQ), but it does do a great job of interacting with databases. It makes creating connections and manipulating data relatively painless.

Developing user interfaces:

Python isn’t like some languages like C# where you have a built-in designer and can drag and drop items from a toolbox onto the user interface. However, it does have an extensive array of graphical user interface (GUI) frameworks — extensions that make graphics a lot easier to create . Some of these frameworks do come with designers that make the user interface creation process easier. The point is that Python isn’t devoted to just one method of creating a user interface — you can use the method that best suits your needs.

.

.

.


Okay then, Lets get down to real business…

(ó ì_í)=óò=(ì_í ò)

.

As mentioned earlier on what my plan is regarding the posts…

I have a Compiled .py (python file) with needed comments covering the most of python basics that was allotted for the days post …I felt that there were too many comment lines inside so I am attaching another copy of the .py file without the long and boring comments, this is for people like me who jump into the heart of the problem and try and get enough experience getting out of it

(¬‿¬)



(✿´‿`)