Algorithms For Dummies. John Paul Mueller

Чтение книги онлайн.

Читать онлайн книгу Algorithms For Dummies - John Paul Mueller страница 24

Algorithms For Dummies - John Paul Mueller

Скачать книгу

      GitHub provides an alternative to Google Drive for saving content. It offers an organized method of sharing code for the purpose of discussion, review, and distribution. You can find GitHub at https://github.com/. The source code for this book appears at https://github.com/lmassaron/algo4d_2ed, so you can access it easily from Colab.

You may use only public repositories when working with GitHub from Colab, even though GitHub also supports private repositories. To save a file to GitHub, choose File ⇒ Save a Copy in GitHub. If you aren’t already signed into GitHub, Colab displays a window that requests your sign-in information. After you sign in, you see a dialog box similar to the one shown in Figure 3-8.

Snapshot shows Using GitHub means storing your data in a repository.

      FIGURE 3-8: Using GitHub means storing your data in a repository.

      Using GitHub gists to save notebooks

      You use GitHub gists as a means of sharing single files or other resources with other people. Some people use them for full projects as well, but the idea is that you have a concept that you want to share — something that isn’t quite fully formed and doesn’t represent a usable application. You can read more about gists at https://help.github.com/articles/about-gists/.

      Most tasks in Colab and Notebook work the same. Each has both code cells and noncode cells, and you can create code cells in both Colab and Notebook by using the options on the Insert menu. Likewise, both environments have noncode cells that come in three forms:

       Text

       Section header

       Form field, which comes in these types:DropdownInputSliderMarkdown

      Noncode cells in Colab work somewhat differently from the Markdown cells found in Notebook, but the idea is the same. Two interesting additions in Colab that aren’t found in Notepad are the scratch code cell, which allows you to experiment with code in real time, and code snippets, which are canned code for performing specific tasks (you just insert them where needed).

      You can also edit and move cells. One important difference between the two environments is that you can’t change a cell type in Colab, but you can in Notebook. A cell that you create as a section header can’t suddenly transform into a code cell. The following sections offer a brief overview of the various features.

      Creating code cells

Snapshot shows Colab code cells contain a few extras not found in Notebook.

      FIGURE 3-9: Colab code cells contain a few extras not found in Notebook.

      You use the icons shown in Figure 3-9 to augment your Colab code experience. Here’s what these features do (in order of appearance, left to right, in the figure):

       Move cell up: Moves the cell up one position in the cell hierarchy.

       Move cell down: Moves the cell down one position in the cell hierarchy.

       Link to cell: Displays a dialog box containing a link you can use to access a specific cell within the notebook. You can embed this link anywhere on a web page or within a notebook to allow someone to access that specific cell. The person still sees the entire notebook but doesn’t have to search for the cell you want to discuss.

       (Optional) Add a comment (assuming that you have the right to make a comment): Creates a comment balloon to the right of the cell. This is not the same as a code comment, which exists inline with the code but affects the entire cell. You can edit, delete, or resolve comments. A resolved comment is one that receives attention and is no longer applicable.

       Open editor settings: Opens the same dialog box shown in Figure 3-2 and discussed in the “Getting familiar with Google Colab features” section, earlier in this chapter. You need to select some code before this option appears.

       Mirror cell in tab: Mirrors the currently selected cell in a Cell pane that appears on the right side of the window. You can scroll wherever you want within the code in the left pane and keep this code accessible. The right-pointing arrow lets you execute the cell at any time after making changes in left-pane code. A pair of double-pointing arrows lets you move the focus back to the selected code in the left pane with a single click. You can also move the cell code to a scratch cell, where you can play with it without modifying your original code. You can have more than one Cell pane. You simply select the one you want and move between them as needed, which lets you move easily from place to place in your code. Close a Cell pane by clicking the X next to the word Cell.

       Delete Cell: Removes the cell from the notebook.

       Vertical ellipses: Contains a number of additional features in a menu (not all of which may appear because they depend on the file you have opened, the tasks you have performed, and your rights to work with the file content):Copy Cell: Copies the content of the currently selected cell to the clipboard.Cut Cell: Deletes the content of the currently selected cell and places it on the Clipboard.Clear Output: Removes the output from the cell. You must run the code again to regenerate the output.View Output Fullscreen: Displays the output (not the entire cell or any other part of the notebook) in full-screen mode on the host device. This option is useful when displaying a significant amount of content, or when a detailed view of graphics helps explain a topic. Press Esc to exit full-screen mode.Add a Form: Inserts a form into the cell to the right of the code. You use forms to provide a graphical input for parameters. Forms don’t appear in Notebook, but because of how you create them, they won’t prevent you from running the code in Notebook. You can read more about forms at https://colab.research.google.com/notebooks/forms.ipynb.

      Code cells also tell you about the code and its execution. The little icon next to the output displays information about the execution when you hover your mouse over it. Clicking the icon clears the output. You must run the code again to regenerate the output.

      Creating

Скачать книгу