Making progress on Python

I had been meaning to learn Python since forever, so a while back I finally sat down to learn it.

I took help of an online tutorial  called Learn Python The Hard Way.
As of this moment, I have completed 23 of the 49 tutorials in the list and I am feeling really excited upon gaining confidence in coding in python. Python is really easy and exciting. I know the exercises I have completed are more like a base to python and are extremely easy given that I have a sufficient background in programming. But I thought it would still be a confidence booster to mark my progress here on the blog. The best part about doing these exercises is that I’m not feeling bored.
I’d like to also document one particular thing I had recurring doubts in while going through these 20 odd exercises. I couldn’t figure out the difference between raw_input() and input() to a definitive degree. But today I can say it with confidence that I have finally understood  the concept:-
1. raw_input(), as the name suggests takes the input from the keyboard in a raw form and spits it out in the form of a string.
Eg. If i write the script:-
#And then i write
print (num, type(num))
#The output will tell me that num is a string
raw_input() doesn’t process or do any computation on the data being fed to it. It just merely takes input from the keyboard and assigns to the variable.
raw_input() is extremely easy to use as compared to input() command, which needs a bit of thinking to do, as explained further.
2. input(), evaluates the input as a python expression rather than passively taking input. It processes the input given to it from the keyboard.
Hence, it expects a syntactically correct expression.
Eg. If i write the script:-
print (num, type(num))

#And then I enter Divyansh, it will give me an error.
#The right string to enter will be ‘Divyansh’,  i.e. Divyansh in single quotes.

When input evaluates the entered string Divyansh, it finds it to be syntactically incorrect and hence shows an error. If I enter ‘Divyansh’, no error is shown and my type() command tells me that I have inputted a string.

The initial exercises taught me a lot of printing in python and I tried various things with the print command. I also started writing a lot of comments, which I feel is a very good practice.
I have also learnt file handling in Python, how to open, close, rename and truncate files. Also revised all the file modes in the files can be opened and different functions associated with file objects to read and write in a file.
Functions in Python are defined using the keyword ‘def’, function definition starts with a ‘ : ‘ and the scope is defined using a indentation.
I love the idea of using indentation to define the scope of your function. This makes Python less messy for short programs and helps you learn it with more easily I believe.
Now I will make a repository on github and upload all my progress there. It will also help me learn how to create a repository and my work will be safe there.
– jigsaw


Leave a Reply

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

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

Google photo

You are commenting using your Google 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 )

Connecting to %s