Code cells contain executable code. The default language that you use in code cells is Python. However, you can choose Kotlin when creating a notebook.
First code cell
By default, the empty code cell is where you start coding in your new notebook. Your cursor is already placed inside this cell.
Write your code.
Click the Run icon in the upper-left corner of the cell to have the code executed. The result of the computation (output) will be displayed in the same cell right under the input.
You can use more run options. For more information, see Code running options.
Add a code cell
You have a few ways to insert a code cell:
- Click the Add code cell button.
Click the + icon on the selected cell to insert a code cell below.
Press Ctrl + Alt + Enter to insert a code cell above the selected one.
Click the ellipsis on the cell toolbar or right-click anywhere in the editor field to select either action from the cell menu.
Now that you have more than one cell in your notebook, you can reorder them:
Press Ctrl + Shift + ↑ or Ctrl + Shift + ↓ to move the selected cell one cell up or one cell down.
Right-click the cell and try the same actions from the cell menu.
Code cell output and view
You can have different kinds of code cell output, including text, tables, graphics, and so on. By default, the layout of a code cell displays both its code and output placed vertically. You can change how they are displayed. Go toand try different options.
For more information, see Editor view.
Collapse inputs and outputs
When working with big notebooks, you may want to collapse some or all of its inputs or outputs. You have the following options:
Collapse all inputs or outputs: go toand select the required action.
Collapse the input or output of a specific cell: click one of the two minus controls on the left side of the cell. To expand it, click the plus control.