Trying to get git!

Woah! Another discovery. The GitLab. It helps manage the source code. Long way to go. Just started using it today and am terribly stumbling with the basics.

Digression: Those times when copy and paste doesn’t work. Try this. Double click on the word to be copied. Then click on where you want to paste it. Press Ctrl + Insert followed by Shift + Insert. And you have your material pasted.

Jupyter is heaven for us Earth beings!

The other day, I was trying to look for a command in R that will restore the Console Window once the plot() command is executed and I landed up with the windows() command. This new discover of windows(width, height, restoreConsole = TRUE) seemed wonderful, but I was about to land up in an even wonderful world. My curiosity shuttle took me to Jupyter Notebook. An amazing open-source web application! You can code in R or Python via Jupyter Notebook. Working with it is super fun and easy. The code looks super neat and the visualizations are wonderful! Give it a try and I am sure most of you will end up loving it!

 

My early experiences with Python programming

I have recently started learning Python programming and will be sharing my experiences (the highs & lows included!) with it. I am a R user and find it to be a wonderful open source programming package. Right now eager to see what Python has in store for me.

I found an interesting feature in Python. It starts counting from ZERO!

Okay, so far I have used R. For accessing say, the first element from a vector in R, I did something like this,

x <- c(‘R’, ‘is’, ‘open source’)
print(x[1])

The output that I get is,

[1] ”R”

Say, I want the third element of the same vector, then,

print(x[3])

And the output is,

[1] ”open source”

Well this was fine with me because, I learnt counting from 1!

But, Python has different rules for counting. As mentioned earlier, the counting begins at Zero. If I write a similar code in Python,

x = [‘R’, ‘is’, ‘open source’]
print(x[1])

This is what I get,

is
Right, I get the second element of the list. So if I want the first element, I should pass this command to Python,
print(x[0])
To which the output is
R

Whereas,

print(x[2])

gives me,

open source

which is the last element of the list.

Also, noticed that Python won’t print a stuff unless the stuff is an argument of the print() command.

Another thing!

There is a module/ library called as os in Python.

I imported this library in Python and used it along with the command listdir to get a list of all files in a specific directory in my device!

import os
a = [file for file in os.listdir(path)]
print(a)

Here, path is the path of the specific folder. Python displays the names of files included in it when the above code is executed. If I want only files ending with specific extensions, (say, .pdf), then the following helps!

import os
a = [file for file in os.listdir(path) if file.endswith(‘.pdf’)]
print(a)

That’s it for the day!