{ "nbformat": 4, "nbformat_minor": 0, "metadata": { "colab": { "name": "Cheat-sheet_for_Google_Colab.ipynb", "provenance": [], "collapsed_sections": [] }, "kernelspec": { "name": "python3", "display_name": "Python 3" } }, "cells": [ { "cell_type": "markdown", "metadata": { "id": "GK9iiMUfziHn", "colab_type": "text" }, "source": [ "# **Cheat-sheet for Google Colab**\n", "\n", "## **In this tutorial, you will learn how to make the most out of Google Colab.**\n", "\n", "![alt text](https://miro.medium.com/max/1400/1*7oukapIBInsovpHkQB3QZg.jpeg)" ] }, { "cell_type": "markdown", "metadata": { "id": "9P7fUbeb04tP", "colab_type": "text" }, "source": [ "# **Introduction**\n", "\n", "[Google Colab](https://colab.research.google.com/notebooks/intro.ipynb) is an amazing tool that lets us build and execute an outstanding data science model and provides us with an opportunity to document our journey. As Google Colab provides us **code cells** to type the code, it also provides us with text cells to add the text. In this tutorial, we will focus more on the **text cell** and see how we can master it by using some simple commands that I will discuss in this tutorial. If you love documenting (like me) then you will enjoy reading this tutorial. You can start exploring Google Colab from below given link. Believe me, it’s an amazing tool.\n", "\n", "**Get your hands on [Google Colab](https://colab.research.google.com/)**\n", "\n", "\n", "\n", "---\n", "\n" ] }, { "cell_type": "markdown", "metadata": { "id": "MDR6gDj70pu8", "colab_type": "text" }, "source": [ "# **Cheat-sheet**\n", "\n", "\n", "Below I will discuss some main handy tricks and shortcuts that can use and become a pro in documenting. If you know [Markdown](https://www.markdownguide.org/), [XML](https://www.w3schools.com/xml/), and [HTML](https://www.w3schools.com/html/) coding then this might be a cakewalk or if you are not familiar with either of those well today is the day to learn them all. Google Colab supports both **Markdown** and **HTML** documentation. You can any of these to document. All right, let’s get started.\n", "\n", "\n", "\n", "\n", "> **To experiment with all of these commands use the “Text cell”**\n", "\n", "\n", "![alt text](https://miro.medium.com/max/1400/1*6N4h9SMdf-NLWEIWAzeEJQ.png)\n", "\n", "\n", "\n", "---\n", "\n", "\n" ] }, { "cell_type": "markdown", "metadata": { "id": "XMhFkLbC6Qop", "colab_type": "text" }, "source": [ "# **Heading**\n", "\n", "Below is the shortcut command for headings. There are different types of headings from Heading 1 to 6.\n", "\n", "\n", "## **Markdown**\n", "\n", "Use `# heading-name`, the more you append `#` the size of the heading decreases as seen below:\n", "\n", "\n", "![alt text](https://miro.medium.com/max/1400/1*FvhQEnugHOYcOu9hTTiloQ.png)\n", "\n", "\n", "## **HTML**\n", "\n", "Similarly, you can use HTML tags such as h1, h2, h3, h4, h5 and h6 for headings as shown below:\n", "\n", "![alt text](https://miro.medium.com/max/1400/1*YeuY2GRIDZc1hZGBG8UGEQ.png)\n", "\n", "\n", "\n", "---\n", "\n", "\n" ] }, { "cell_type": "markdown", "metadata": { "id": "nGzrviJr-lOD", "colab_type": "text" }, "source": [ "# **Bold**\n", "\n", "Bold make the text bolder and increases the text’s visibility.\n", "\n", "## **Markdown**\n", "\n", "To make the text bold in markdown surround it by `**` (two stars) for example `**Text-to-be-bold**`.\n", "\n", "![alt text](https://miro.medium.com/max/1400/1*F10Z_262d18oRCRuIPUJtw.png)\n", "\n", "## **HTML**\n", "\n", "Using HTML we can bold the text by using the b tag as seen below:\n", "\n", "\n", "![alt text](https://miro.medium.com/max/1400/1*gd_RowfxD646hGn4jkqwCQ.png)\n", "\n", "\n", "\n", "---\n", "\n", "\n", "\n" ] }, { "cell_type": "markdown", "metadata": { "id": "6g5GVsF4z9jb", "colab_type": "text" }, "source": [ "# **Italicize**\n", "\n", "Similar to bold the text can also be italicized\n", "\n", "## **Markdown**\n", "\n", "To make the text italicize in markdown surround it by `*` (one star) for example `*Text-to-be-italicize*`\n", "\n", "![alt text](https://miro.medium.com/max/1400/1*qnD2cKIhia7pxGUwXDtHGQ.png)\n", "\n", "\n", "## **HTML**\n", "\n", "Also, this can be written in HTML using the i tag as shown below:\n", "\n", "![alt text](https://miro.medium.com/max/1400/1*P0g65RLoMraJ8820WzToPw.png)\n", "\n", "\n", "\n", "---\n", "\n", "\n", "\n" ] }, { "cell_type": "markdown", "metadata": { "id": "3nggQoCC0Xzw", "colab_type": "text" }, "source": [ "# **Strikethrough**\n", "\n", "Used to strike through the text. A **horizontal line** is drawn in the middle of the text.\n", "\n", "## **Markdown**\n", "\n", "To strikethrough, the text in markdown surround the text with two tilde’s character `~~`, such as `~~Text to be striked~~`.\n", "\n", "![alt text](https://miro.medium.com/max/1400/1*5vU7QHc4XS0YMA9jHUbFLg.png)\n", "\n", "## **HTML**\n", "\n", "In HTML we can use the s tag to strikethrough the text.\n", "\n", "![alt text](https://miro.medium.com/max/1400/1*ONCvW5n_qqrnhFBXwb4mFg.png)\n", "\n", "\n", "\n", "---\n", "\n", "\n", "\n" ] }, { "cell_type": "markdown", "metadata": { "id": "bUvQF5ih0u4Y", "colab_type": "text" }, "source": [ "# **Combination**\n", "\n", "Also, we can combine all the formatting commands and style the text as shown below.\n", "\n", "## **Markdown and HTML**\n", "\n", "![alt text](https://miro.medium.com/max/1400/1*h1y2_-st5Rugd2sDXSkUJQ.png)\n", "\n", "\n", "\n", "---\n", "\n" ] }, { "cell_type": "markdown", "metadata": { "id": "zKimFHlT05w_", "colab_type": "text" }, "source": [ "# **Lists**\n", "\n", "As we all know there are two types of lists:\n", "\n", "\n", "\n", "1. **Ordered List**\n", "\n", "2. **Unordered List**\n", "\n", "As the name suggests an ordered list has an order (1, 2, 3,… or other). But an unordered list has no order, as shown below.\n", "\n", "## **Ordered and Unordered list in Markdown**\n", "\n", "In markdown for the ordered list, you can straightaway just type numbers like `1, 2, 3, and so on`. But for the unordered list, you can start with a `*` and this intern creates a bullet list.\n", "\n", "![alt text](https://miro.medium.com/max/1400/1*vBRF_lB35gRkuH09Msx9bA.png)\n", "\n", "## **HTML**\n", "\n", "We can use the HTML tags to play with the lists as shown below:\n", "\n", "## **Ordered list**\n", "\n", "In the ordered list there are **normal list, type 1, A, a, I, i types** as shown below:\n", "\n", "**Normal list**\n", "\n", "Use the `ol` tag and for the list contents use the `li` tag as shown below:\n", "\n", "![alt text](https://miro.medium.com/max/1400/1*kcDBziqmKvYyl3Hv_LBUiw.png)\n", "\n", "**Type = “1”**\n", "\n", "Just add `type = \"1\"` inside the ol tag this will create an ordered list of **1, 2, 3, and so on**. The list items will be numbered with numbers (default).\n", "\n", "![alt text](https://miro.medium.com/max/1400/1*09W5HYQIUJ4LcfJPWw1vsQ.png)\n", "\n", "**Type = “A”**\n", "\n", "Just add `type = \"A\"` inside the ol tag this will create an ordered list of **A, B, C, and so on**. The list items will be numbered with uppercase letters.\n", "\n", "![alt text](https://miro.medium.com/max/1400/1*67oeYyf0gfliUoqI0ABDpg.png)\n", "\n", "**Type = “a”**\n", "Just add `type = \"a\"` inside the ol tag this will create an ordered list of **a, b, c, and so on**. The list items will be numbered with lowercase letters.\n", "\n", "![alt text](https://miro.medium.com/max/1400/1*vtCQpk6uO2DpU3KKmfqtLg.png)\n", "\n", "\n", "**Type = “I”**\n", "\n", "Just add `type = \"I\"` inside the ol tag this will create an ordered list of **I, II, III, and so on**. The list items will be numbered with uppercase roman numbers.\n", "\n", "![alt text](https://miro.medium.com/max/1400/1*rt09GDABSFkU502NmSH9_g.png)\n", "\n", "**Type = “i”**\n", "\n", "Just add `type = \"i\"` inside the ol tag this will create an ordered list of **i, ii, iii, and so on**. The list items will be numbered with lowercase roman numbers.\n", "\n", "![alt text](https://miro.medium.com/max/1400/1*dN-5gR4xgtf9jwWF_ZOYtw.png)\n", "\n", "\n", "\n", "\n", "---\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n" ] }, { "cell_type": "markdown", "metadata": { "id": "aeHA8KFP9yhO", "colab_type": "text" }, "source": [ "## **Unordered list**\n", "\n", "In the ordered list there are **normal list, disc, square, circle, and none types** as shown below:\n", "\n", "**Normal list**\n", "\n", "Use the `ul` tag and for the list contents use the `li` tag as shown below:\n", "\n", "![alt text](https://miro.medium.com/max/1400/1*Q6gRYUpdx1RX5DTrPsuQPQ.png)\n", "\n", "\n", "\n", "---\n", "\n", "**Disc**\n", "\n", "Just add `type = \"disc\"` inside the `ul` tag to create a disc-shaped list.\n", "\n", "![alt text](https://miro.medium.com/max/1400/1*_O-1sIf7JZadHKG71gOvWw.png)\n", "\n", "---\n", "\n", "**Circle**\n", "\n", "Just add `type = \"circle\"` inside the `ul` tag to create a circle-shaped list.\n", "\n", "![alt text](https://miro.medium.com/max/1400/1*sfDKOF21OqcLoEYLiZ8lcw.png)\n", "\n", "---\n", "\n", "**Square**\n", "\n", "Just add `type = \"square\"` inside the `ul` tag to create a square-shaped list.\n", "\n", "![alt text](https://miro.medium.com/max/1400/1*4G-LWW2LWiZM1VpJPqSgDA.png)\n", "\n", "---\n", "\n", "**None**\n", "\n", "Just add `type = \"none\"` inside the `ul` tag to create a none-shaped list. In this case, the list will have no points as shown below:\n", "\n", "![alt text](https://miro.medium.com/max/1400/1*jXzBSc7gnBClrvDqmJpSWA.png)\n", "\n", "---\n", "\n", "## **Description list**\n", "\n", "\n", "A description list is a list of terms, with a description of each term. The `dl` tag consists `dt` which defines the name of the list and the `dd` tag describes each list.\n", "\n", "![alt text](https://miro.medium.com/max/1400/1*D8XzV7hC0Zro_Zzm8o0Fpg.png)\n", "\n", "\n", "---\n", "\n", "## **Nested list**\n", "\n", "Nested lists are basically lists within lists.\n", "\n", "![alt text](https://miro.medium.com/max/1400/1*S4WnDBD2Xty4DDVRw-ggYQ.png)\n", "\n", "---\n", "\n", "## **Control list counting**\n", "\n", "An ordered list will start counting from 1. If you want to count from a specified number, you can use the `start` attribute as shown below:\n", "\n", "![alt text](https://miro.medium.com/max/1400/1*1Ab0qTWvQY08l9NWA1S8Rw.png)\n", "\n", "To know more in-depth about the list in HTML please refer to the article below:\n", "\n", "[HTML Lists](https://www.w3schools.com/html/html_lists.asp)\n", "\n", "---\n", "\n", "\n", "\n", "\n", "\n", "\n" ] }, { "cell_type": "markdown", "metadata": { "id": "GevI4Wn3_5dH", "colab_type": "text" }, "source": [ "# **Links**\n", "\n", "Links or hyperlinks allow users to click their way from page to page.\n", "\n", "## **Markdown**\n", "\n", "In markdown write the title of the link inside square brackets `[ ]` and write the webpage address inside round brackets or parenthesis `( )`. **Make sure you write the title first, followed by the link.**\n", "\n", "![alt text](https://miro.medium.com/max/1400/1*QJf4inbel4zdf9i8hndr3g.png)\n", "\n", "## **HTML**\n", "\n", "In HTML for the hyperlinks, you can use the anchor `a` and `href` tag as shown below:\n", "\n", "![alt text](https://miro.medium.com/max/1400/1*X0kAxZW6CfbXl81PHdyu6Q.png)\n", "\n", "---\n", "\n", "\n", "\n" ] }, { "cell_type": "markdown", "metadata": { "id": "x0uw8MxNCBlz", "colab_type": "text" }, "source": [ "# **Images**\n", "\n", "Sometimes **one image is worth one thousand words**. People can easily understand the concepts better by seeing an image.\n", "\n", "## **Markdown**\n", "\n", "Similar to the link you need to insert the link of the image inside the parenthesis. Make sure you append `!` at the beginning. If your link is broken or not valid, then the `alt text` would be displayed.\n", "\n", "![alt text](https://miro.medium.com/max/1400/1*Bk6dec-nG1PuAJv3PjZq9w.png)\n", "\n", "**Image hover**\n", "\n", "You can simultaneously hover on the text to see the title of the image. To do this, you can put the text of your choice inside the command as shown below:\n", "\n", "\n", "\n", "```\n", "![alt text](https://media.makeameme.org/created/online-class-cant.jpg \"Online Class Memes\")\n", "\n", "```\n", "## **HTML**\n", "\n", "In HTML we can include an image using the img tag and you need to provide the source of the image to the src tag.\n", "\n", "**Adjusting height and width**\n", "\n", "You can adjust the **height** and **width** of the image. Also, you can embed a **GIF** image too as shown below.\n" ] }, { "cell_type": "markdown", "metadata": { "id": "6WCRQdaPC6__", "colab_type": "text" }, "source": [ "![alt text](https://miro.medium.com/max/1400/1*iFiRv_AlSwL5RQ8tkTf_6w.png)" ] }, { "cell_type": "markdown", "metadata": { "id": "8iCcNEZJDS9L", "colab_type": "text" }, "source": [ "**Images along with captions**\n", "\n", "It’s a great practice to give credit to the images taken from different sources (I mean citing the images or providing the captions). With the help of `figcaption` tag we can provide captions to the images.\n", "\n", "![alt text](https://miro.medium.com/max/1400/1*9IWjFlKTBogYWuH3G1zKhw.png)\n", "\n", "You can play with the `align` tag and try to align the caption according to your preference.\n", "\n", "---" ] }, { "cell_type": "markdown", "metadata": { "id": "jwK2yGZZDeLH", "colab_type": "text" }, "source": [ "# **Format the code**\n", "\n", "There are two things that you need to understand here are:\n", "\n", "\n", "1. **Inline Code**\n", "2. **Syntax highlighting**\n", "\n", "\n", "## **Inline Code**\n", "\n", "Sometimes you might want to insert a few code samples you can use Inline codes. To use the inline code, you can use the **backticks (``)**. Surround it with backticks as shown above.\n", "\n", "\n", "![alt text](https://miro.medium.com/max/1400/1*jTJnPDH_LY7SHoA8NCSFgw.png)\n", "\n", "---\n", "\n", "## **Syntax highlighting**\n", "\n", "This is used when you write **huge lines of codes** inside Google Colab’s text editor. Sometimes including huge python code snippets is not a good idea using inline codes, use syntax highlight in this case. You must embed the code within ` ``` ` as shown below:\n", "\n", "\n", "**Default syntax highlighting**\n", "\n", "This works irrespective of any programming language.\n", "\n", "![alt text](https://miro.medium.com/max/1400/1*uBqi2TGiII8XGUWFNFN3Wg.png)\n", "\n", "\n", "**Python syntax highlighting**\n", "\n", "This can be used explicitly for **python** programming. You should include the name `python` at the beginning.\n", "\n", "![alt text](https://miro.medium.com/max/1400/1*8ikLv5cwvPAawt97Q1xrTg.png)\n", "\n", "\n", "**Javascript syntax highlighting**\n", "\n", "This can be used explicitly for **JavaScript** programming. You should include the name `javascript` at the beginning.\n", "\n", "![alt text](https://miro.medium.com/max/1400/1*mjXD9EB0ZQCYFBBZdgs4KQ.png)\n", "\n", "**C programming syntax highlighting**\n", "\n", "This can be used explicitly for **C** programming. You should include the name `c` at the beginning.\n", "\n", "![alt text](https://miro.medium.com/max/1400/1*28aomzI0HhUJHxphJfpfZw.png)\n", "\n", "\n", "As seen above you can highlight the code snippets based on different programming languages.\n", "\n", "---\n" ] }, { "cell_type": "markdown", "metadata": { "id": "qbM4U1JpE4nJ", "colab_type": "text" }, "source": [ "# **Tables**\n", "\n", "There are a few times you might want to represent the information in the form of **tables**.\n", "\n", "## **Markdown**\n", "You must use the `|` as an operator for different columns. By default, the table headers would be in bold.\n", "\n", "![alt text](https://miro.medium.com/max/1400/1*7FdxLfShsePvU_FQ-qqS3Q.png)\n", "\n", "\n", "\n", "> Colons can be used to align columns.\n", "\n", "\n", "If you need to create any table then use the below [tool](https://www.tablesgenerator.com/) to generate tables for you. All you have to do select the type of table generators such as **Latex, HTML, Markdown, and others**. Enter the contents inside the table and then click on **Generate**. You can then copy-paste the generated code in the text editor and see a beautiful table without minimum effort.\n", "\n", "[Create LaTeX tables online](https://www.tablesgenerator.com/)\n", "\n", "\n", "\n" ] }, { "cell_type": "markdown", "metadata": { "id": "yypy10LGFVs5", "colab_type": "text" }, "source": [ "## **HTML**\n", "\n", "In the case of HTML, you must use the `table` tag along with `tr` which is for the table rows and `th` is for the table headers (**Company Name and Founder**) in this case. The `td` is for the table description.\n", "\n", "![alt text](https://miro.medium.com/max/1400/1*ShqEpogTHh9pA95sWjA2DQ.png)\n", "\n", "\n", "You can also use the `align` tag and align the contents accordingly.\n", "\n", "---\n", "\n", "\n", "\n", "\n" ] }, { "cell_type": "markdown", "metadata": { "id": "5p2pJu5qFqD5", "colab_type": "text" }, "source": [ "# **Indent**\n", "\n", "This is very useful when you need to differentiate some text like **NOTE, HINT** or any extra useful information.\n", "\n", "## **Markdown**\n", "\n", "You need to use the `>` for the indentation.\n", "\n", "![alt text](https://miro.medium.com/max/1400/1*e3s2rKSTdp0RmxlmbdkmYw.png)\n", "\n", "\n", "## **HTML**\n", "\n", "Similarly in HTML you can use the `blockquote` tag for the same purpose.\n", "\n", "![alt text](https://miro.medium.com/max/1400/1*zS3GwuK3SmFQq_6Jt-GsUA.png)\n", "\n", "\n", "---" ] }, { "cell_type": "markdown", "metadata": { "id": "Ff72HabtF8qc", "colab_type": "text" }, "source": [ "# **Horizontal Ruler**\n", "\n", "\n", "It is often a wonderful practice to draw a horizontal ruler after every chapter, or any concept while you are writing. This just helps in differentiating things from one another.\n", "\n", "## **Markdown**\n", "\n", "In case of markdown, you need to just use 3 `---` (Minus).\n", "\n", "![alt text](https://miro.medium.com/max/1400/1*VSkk-UQvxbGom2bVCIvAwQ.png)\n", "\n", "## **HTML**\n", "\n", "In case of HTML, you need to use the tag `hr` for inserting a horizontal ruler.\n", "\n", "![alt text](https://miro.medium.com/max/1400/1*H5kmuc_KSaRB90FOCZfMpQ.png)\n", "\n", "\n", "---" ] }, { "cell_type": "markdown", "metadata": { "id": "8fFhNQ2EGOcR", "colab_type": "text" }, "source": [ "# **Justify**\n", "\n", "Often many times you will write big paragraphs in your notebooks, but sometimes you might want to justify them just to make it look neat. Here, you can use the `align` tag with `justify` as a value.\n", "\n", "![alt text](https://miro.medium.com/max/1400/1*liOB0s27ECQUhWd-HGKgsw.png)\n", "\n", "\n", "![alt text](https://miro.medium.com/max/1400/1*P_hLZhBhf4OZYRdJ3nJyYg.png)\n", "\n", "\n", "\n", "Similarly, you can use `right`, `left`, and `center` values and **align** the paragraph accordingly.\n", "\n", "---" ] }, { "cell_type": "markdown", "metadata": { "id": "D9OUtQoEGzkY", "colab_type": "text" }, "source": [ "# **Line break**\n", "\n", "Some times you might want to start a new paragraph, so you will need to put a line break in between both of them. There are two options here either you can just press the **“Enter”** key and leave a line of space in the between or you can use the `br` tag also called a line break.\n", "\n", "![alt text](https://miro.medium.com/max/1400/1*yJ3VKVl-q7yeYn_Uw_5EXg.png)\n", "\n", "---" ] }, { "cell_type": "markdown", "metadata": { "id": "f0QXq854HEPf", "colab_type": "text" }, "source": [ "# **Mathematical formulas**\n", "\n", "If you are using the notebooks for research purpose then you need to write a lot of equations and mathematical symbols.\n", "\n", "## **Symbols**\n", "\n", "Make sure you write the symbol name between `$` and start with `\\` after the first `$`.\n", "\n", "![alt text](https://miro.medium.com/max/1400/1*578h3YR_ItAA1O9lQNkcjQ.png)\n", "\n", "\n", "## **Equations**\n", "\n", "Follow the same rules i.e surround the equations between `$` and start with `/` after the first `$`.\n", "\n", "![alt text](https://miro.medium.com/max/1400/1*5tRMzSc_wLHIXB3rNrKi5Q.png)\n", "\n", "To see more about the mathematical equations and symbols, please refer to the [link](https://csrgxtu.github.io/2015/03/20/Writing-Mathematic-Fomulars-in-Markdown/) below:\n", "\n", "[Writing Mathematical Formulas in Markdown](https://csrgxtu.github.io/2015/03/20/Writing-Mathematic-Fomulars-in-Markdown/)\n", "\n", "---" ] }, { "cell_type": "markdown", "metadata": { "id": "cpwJU3p4Hske", "colab_type": "text" }, "source": [ "All right, folks, that’s the end of the tutorial. I hope you learned many new things today. I tried to keep this tutorial short but as there were many concepts I had to maximize it. But this cheat-sheet will be useful in most of the interviews (**technical documentation**) or when you are documenting your Jupiter notebooks. If I find more tips and tricks, then I will provide the details here. Until then, stay safe and have a wonderful day. See you next time." ] } ] }