Python – A sneak peak into the technology!!

Python, a programming language of the future invented by Guido van Rossum in the year “1991”.

I believe he was alien…I hope you do too… Kidding!!! Or not…

This particular language unlike The JAVA is known to be easy, needs no special compilers so can work on different platforms, has syntax’s like a language you talk, can be treated like a brother, friend and even a partner…. I mean in a way, comparing the way we can write the code, the procedural way, an object-oriented way or even a functional way.

To put things in perspective, python relies mostly on indentation, and to mark scope for pieces of code like loops, functions and classes it uses ‘spaces’, yeah WHITE SPACES. Easy much….Actually, It is easy…but again it depends on how good you absorb the concepts technically.

If you see the reason for the design of such a programming language, somewhere it will be mentioned that python was designed for readability like it wants to be English language with a sway of mathematics.

As an IT guy, I always want to be ahead in the technology race but it’s practically impossible to grasp and work in everything at the time. This language needs to be practices worshiped and then you have to give yourself up to master this. And this is true story…

Please install the python’s latest version from python.org

If you want an IDE, JUPYTER makes life hell lot easy, of course there are others like the PYCHARM, Thonny, eclipse/netbeans, many online editors etc..,

Okay, I will stop this non-technical stuff and actually dive into the language basics for you in this article.

Please understand this below “>>>” whatever is written below after this symbol is an output.

But you’re a programmer you will know this. For those of who don’t drop a thanks :-}

So first up, Comments & Howdy Python!! (Hello World…anything)

#This is a comment

>>> Print(“Howdy Python/Hello World!”)

Hello, World!

In python, there is no need to pre declare variables, it has no command for declaring a variable unlike other languages. Fun right….

So, A variable is (or) can be created the moment you first assign a value to it.

Like this,

Var_Num = 369
Name_Person = “Guru”

Person_Profession=”being god”


Print all the above and you’d be surprised to find me a god 😛 ….

Python has a few built in data types (this is obvious),

Text Type:Str
Numeric Types:int, float
Sequence Types:list, tuple, range
Mapping Type:Dict(dictionary)
Set Types:set, frozenset
Boolean Type:Bool
Binary Types:Bytes & bytearray

Using many type of data, how does the programmer know what is being fed into the variable and also sometimes we wonder what type of data is in a variable, to make life easy we have the TYPE() function which lets us know the datatype of the variable.

Note: Always use print to printout 😛 

Example: print(type(VAR_Num)) >>>class ‘INT’

We can also try this with all types of data as mentioned in the above table.

We can also apply the type to a value and cast is another,

Example, I need the value of V_PI=3.14159 stored in VAR_PI. But I need only 3 to be printed outhow do I go about it ?

Simple, VAR_PI=int(V_PI)

So this has actually fed 3 to the VAR_PI.

Good right… it gets better, Strings.. are the best to handle in PYTHON…

One line/word string are easy as such, they can be put into “xsxsxs” or ‘xsxsx’ …and mean the same ..no bias..

The best part is if you have a para with multiple lines, you just “””asasdasd””” put it under three single/double quotes and it will be accepted a valid string.

To have fun with BOOL’s

We’ve got like few operations to perform,

Say,

print(369 > 360) >>> True

print(36 == 69) >>>False

print(69 < 36) >>>False

Goinf to the crazier stuff of python,

There are four collection types in the Python:

List: which is ordered and changeable. Allows duplicates.

Tuple: which is ordered and unchangeable. Allows duplicates.

Set: which is un ordered and un indexed. No duplicates allowed.

Dictionary: which is un ordered, changeable and indexed. No duplicates allowed.

When writing an efficient algorithm we must pick the right kind of collection to increase efficiency and run time of our program.

List Example:

Thisisalistofnames = [“guru”, “mumba”, “sandy”]
print(thisisalistofnames)

>>>[“guru”, “mumba”, “sandy”]

thistuple = (“guru”, “mercedes”, “goldenret”)

print(thistuple)

>>> (“guru”, “mercedes”, “goldenret”)

thisisaset = {“guru”, “mumba”, “sandy”}
print(thisisaset)

>>> {“guru”, “mumba”, “sandy”}

thisisadictionary = {“brand”: “bmw”,”model”: “racecar”, “year”: 2015}

print(thisisadictionary)

>>> {“brand”: “bmw”,”model”: “racecar”, “year”: 2015}

Functions in Python: Simple, just define it 😛 no I mean literally just define it.

Example:

def A_function():
  print(“Hello world from a function”)

A_function()  #Can be called like this elsewhere in a program

Lets talk about another function of python THE LAMBDA,

This is a kind of function that’s small, anonymous and easy to write. It can take any number of arguments, but can only have one expression associated.

For example:  let’s say trial_lamb multiplies 2 variables.

trial_lamb = lambda var_a, var_b : var_a * var_b
print(trial_lamb(10, 10))

>>>100                                            

Huh… So that’s it…. Simple right…

You can learn this too…

Please know, Python as a language has involved itself in many many many domains like IOT, ML, AI,Data Science, Big Data, Web scripting’s, network security etc.., and many many many more aspects of it exitsts that are currently being mastered by our author.

These aspects of the language will be shared in a future series with many more great examples.

Also, did you know?

  • The founder of this language, Guido Van Rossum worked for google.
  • The name Python isn’t from the snake python but he was so inspired from the BBC comedy series Montie Pythons flying circus.

Please kindly refer our website for more articles on varied topics.

This is a technology series that will have updates. Watch this space for more. Happy coding, keep learning. Believe you change the world and in the end you will.

Advertisements

Leave a Reply

%d bloggers like this: