MR_Lab_1_IntroductionToNotebook
ipynb7 kBPython · 10 cellsIn Lab 1: Introduction to notebooks
Introduction to Artificial Intelligence
-- At the end of this session, you will be able to :
- Create and manage the Jupyter Notebooks environment to run code, insert text and math equations.
- Perform basic matrix manipulations using Numpy.
Intro to Jupyter Notebook
-- Here, we will only cover the basics.
Jupyter Notebook is based on the .ipynb format (iPython Notebook), and is essentially a way to do rapid prototyping / demonstrations of scientific python. The basic idea is to define cells. Cells can be of several types, including python code, or rich text (using markdown formatting).
When a code cell is evaluated (i.e. the python code will be executed), the output of this evaluation will show up right below the cell.
When a text cell is evaluated, the text will be formatted.
You can now do the "User Interface Tour" from the Help menu.
When working with Jupyter Notebook, you will essentially switch between two modes :
- The Edit mode in which you edit the content of the cells
- The Command mode, that enables you to change the cell types.
When in Command mode, you can select cells. If you select a single cell, you can edit it by simply pressing enter, or double clicking on it.
For example, try editing THIS CELL and change its content.
Now, edit the cell below, change the code, and when you're done, press Shift+Enter to evalute the code.
### CELL TO BE EDITED
a=32
b= 2*a
print("%d + %d"%(a,b))
### CELL TO BE COMPLETED 32 + 64
Note that using Jupyter Notebook, if you evaluate a cell with a function followed by a ? sign, the help of the function will pop up.
Example :
import os
os.listdir?[31mSignature:[39m os.listdir(path=[38;5;28;01mNone[39;00m) [31mDocstring:[39m Return a list containing the names of the files in the directory. path can be specified as either str, bytes, or a path-like object. If path is bytes, the filenames returned will also be bytes; in all other circumstances the filenames returned will be str. If path is None, uses the path='.'. On some platforms, path may also be specified as an open file descriptor;\ the file descriptor must refer to a directory. If this functionality is unavailable, using it raises NotImplementedError. The list is in arbitrary order. It does not include the special entries '.' and '..' even if they are present in the directory. [31mType:[39m builtin_function_or_method
You can also display the code of a function using the syntax "??"
B = 2.5
B?[31mType:[39m float [31mString form:[39m 2.5 [31mDocstring:[39m Convert a string or number to a floating-point number, if possible.
### CELL TO BE COMPLETED