What is Google Colab? That’s our first question. The second question is, is it free to use? We’ll answer these questions in this section.
First thing first.
Google Colab is an interactive environment and it runs in the Cloud where you can write Python code and execute, seeing the result instantly.
Basically it’s to run Jupyter notebooks in the cloud.
On the other hand, Google Colab is free.
All you need is a Gmail account to sign in so that you can save your works in the Google Drive as well as in your GitHub repository.
In addition we can use the Graphics Processing Unit or GPU for free. However, it has a limit. We can use the GPU for 12 hours continuously.
In our previous section, we have seen how we can plot a single vector using the Matplotlib library.
Certainly we have done it locally and got an output as follows.
![Matplotlib plots a single vector, when value is 6 on the x axis and 3 on the y axis, however it starts from (4, 4)](https://i0.wp.com/sanjibsinha.com/wp-content/uploads/2022/06/Matplotlib-plots-a-single-vector-when-value-is-6-on-the-x-axis-and-3-on-the-y-axis-however-it-starts-from-4-4.jpg?ssl=1)
Let’s take a look at the code also.
import matplotlib.pyplot as plt
# a Vector can originate anywhere, yet we can set location
X = [0]
Y = [0]
# Directional vectors
U = [6]
V = [3]
# Creating plot
plt.quiver(X, Y, U, V, color='b', units='xy', scale=1)
plt.title('Single Vector')
# x axis limit and y axis limit
plt.xlim(-10, 10)
plt.ylim(-10, 10)
# Show plot with grid just like a graph paper
plt.grid()
plt.show()
We had run the same code and got the output instantly.
![Google Colab output](https://i0.wp.com/io.sanjibsinha.com/wp-content/uploads/2022/06/Google-Colab-output.jpg?ssl=1)
As we see, it gives you the output instantly.
Moreover, we can change the value any time and test it.
For that we don’t have to open our Jupyter notebooks, or any code editor like Visual Studio.
After all, whatever we write and test locally, we ultimately save it in the Cloud. Right?
Advantages of using Google Colab
Google Colab allows you to save it in Google Drive, share it with fellow developers and add the file to GitHub.
One of the greatest advantages is we can test the code instantly.
Let’s change the above code to plot the single vector in such a way that it moves in the opposite direction.
Therefore we have to change the magnitude and direction both.
As a result our new code looks the following.
import matplotlib.pyplot as plt
# a Vector can originate anywhere, yet we can set location
X = [0]
Y = [0]
# Directional vectors
U = [-6]
V = [-3]
# Creating plot
plt.quiver(X, Y, U, V, color='b', units='xy', scale=1)
plt.title('Single Vector')
# x axis limit and y axis limit
plt.xlim(-10, 10)
plt.ylim(-10, 10)
# Show plot with grid just like a graph paper
plt.grid()
plt.show()
As an outcome, we have the output as follows.
The arrow points in the opposite direction.
![Google Colab allows to change code and gives output instantly](https://i0.wp.com/sanjibsinha.com/wp-content/uploads/2022/06/Google-Colab-allows-to-change-code-and-gives-output-instantly.jpg?ssl=1)
Another advantage is we don’t have to use the local system resource.
In addition, we can save it where we want to save the file. Either in Google Drive or GitHub.
![Google Colab sharing and saving options](https://i0.wp.com/sanjibsinha.com/wp-content/uploads/2022/06/Google-Colab-sharing-and-saving-options.jpg?ssl=1)
In this short overview we have not covered all the features here.
But in the future as we will work more on Data Science using Machine Learning Algorithms, we’ll find that Google Colab is really helpful in every respect.
Leave a Reply