A new experience – Diving into python.

A new experience – Diving into python.

Python! The word which suits the Python programming language very well. Today was the first day of my python experience and really, the flexibility it gives us is unreal. Python makes concepts like resizing a list(array), declaring variable, declaring functions and reversing a string a child’s play.

Just to give you all a perspective of the awesomeness of Python, following are few examples,

  • No semicolons –

Oh yeah! You read it right. No semicolons. Remember of the time when as a beginner you write a program after a lot of efforts and think that you have done it all right but when you compile it you get an error which you can’t understand. That annoying error which you ignore without even reading it properly. There is no sign of anything like that in Python. Just write your code right away without any worry of missing a semicolon at the end of each line.

  • Variables –

To declare a variable in Python, just declare a variable by giving it any random name and assign a value to it as follows, while in other languages like Java you first have to specify the type of the variable and then only you can assign a value to the variable. This may seem too trivial to you but trust me, this is really very cool.

#Python code (the text followed by a '#' is a comment)
myint = 7
print(myint)
#Equivalent Java code
int myInt = 7;
System.out.print(myInt);

Now suppose you want a variable initialised with a floating point data. All you have to declare a variable as about but instead of a integer assign a floating point data as follows-

myint = 7.0
print(myint)

But in Java you have to declare a variable as a float data type and then only you can assign a floating point data in that variable.

  • No compiling –

Exactly! How a code can run without being compiled?! Unlike Java and C++, Python is a interpreted language and the python interpreter just takes your program(saved in a .py file) and do some magic on that and give you a running program in your terminal. So a big no no to “javac meraProgram.java” and “gcc meraDusraProgram.cpp”.

  • Python gives you Power –

I love math and the way Python can do it, no other language can achieve even that level. In Python, if you want to raise a number(lets say x) to the power of another number(lets say, y) then all you have to do is this little thing,

#this will print x^y
print(x**y)

So just to give you an essence of Python’s power, I tried to raise 111111 to the power of 111111. I was expecting an error or something but surprisingly I got this-

13728804742448318994324468442958804389279509389382055883974280747060245970
32575002029785077174993789237685616634115112387743612818619455952524518861
75329105420788483184793160333163229669749236507100843921224506237175219272
62131598157001111608586221501972805849619651339464804955876354616353016996
42840445085193401715008490723627987471718499536159450800991557919054928905
15111026945092129899689743239279589660779820991637482043995501958285781253
56169975183732236108166794869452064381029058228728828541837044031787746140
96570711683502777369048138262504230535380079718822063604417927021806406343
73026653729358657757487389865605916560959815112692735890258621991825289344
37614158415504150704226810572991583792507540538740828210405440764368056605
55807682614092486944629882433960212784113741731752607201642464920131978155
93737995575791476294112353469951241530560123010486874954691984610638504426
95475769060678743313719226360534838315881827425860986062489916534355797013
45188211633151731677112509934355332990131020449924759644517011951921451577
27804146533681697765969174821165140959079970639952303833185523476231201868
56796375801930600807016205835199303563850998625943995971102800732902200200
51373122730571820995408669698656779816986081794553128931530261378660089111
# and guess what, I have pasted just 1/8th of the output here. 
# Try it yourself

This is my first day with Python and I am very much fascinated by the language. I will keep sharing my views on Python as I progress in learning it.


Places where this Python is dangerous-

My Mother always says “Junglee janwar junglee hi hote he, kabhi bharosa nahi karna chahiye unko(Wild animals should never be trusted).” and if you are a beginner, just stay away from this Python. Although Python has a really low learning curve, I think python is the worst language for a person who is totally beginner to the field of programming. Its concepts make you lazy. You can do a given task in lesser number of keystrokes than any other programming language and if you are a beginner, this language makes it really hard for you to understand basic(but extremely important) concepts like pointers, data types, variable scope, string manipulation etc. of other programming language like C++ and Java.

-Abhay Maniyar

Advertisements

2 thoughts on “A new experience – Diving into python.

  1. Hi! As a computer science tutor who teaches both Java and Python, I have to say that I almost always prefer to teach Python over Java (even though I work in Java full time at my day job). Many students get easily confused when they have to do things such as compile a Java file and this can cause them to feel overwhelmed and get discouraged.
    Python is nice in the regard that you can fire up IDLE and get busy. What do you think?

    Liked by 1 person

    1. I totally agree with you. It’s really very easy to work on Python as compared to Java. Less number of keystrokes, total control over system through libraries, easy syntax. All these things make it easy for beginners to get interested in programming.

      Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s