Course address: https://www.imooc.com/learn/943
2. How to open jupyter notebook
Open method 1:
Create a directory under the C drive
Open method 2:
3. Simple to use
Create an empty folder - copy the directory path - cmd switches to the directory - enter jupyter notebook
Note: If the first option is not checked, the second method cannot be used
Create a notebook:
Create a title:
Write code:
Press and hold "shift+enter" to execute
Write notes:
Press and hold "Esc" to switch the mode, the "Y" unit goes to the code state, and the "M" unit goes to the markdown state (note mode). Enter Enter key to confirm
Press and hold "shift+enter" to exit; double-click to continue modifying
The number becomes a serial number, a space is required
* becomes a dot
Add a new line of command:
Delete a line of command:
hot key:
"ctrl+s"--save
"z" -- undo
copy and paste
Moving up and down
terminal, restart to clear
4. Simple Tutorial
4.1 Arrays/Arrays
shape
3 in a row
2 rows and 3 columns
'-1' is a placeholder
Modify an element in an array
zeros
4.2 Index operations
wrong spelling
array operations
Second +10 per line
produces an array of the specified range
Another way to write +101
Another way to write +102
4.3 Element Data Types
4.3 Array operations and common functions
a+b
a-b
a*b
a/b
Prescribing
Matrix Multiplication Operation
The number of columns of a = the number of rows of b to perform matrix operations
sum
Sum operations on rows and columns in an array
average value
random number
repeat
By default, each row is sorted from small to large
Sort each column from small to large and return the subscript
sort
Matrix transpose
4.4 Broadcast
If the array is large, the loop calculation will be very slow
tile implementation
Broadcasting - you can add arrays of different dimensions, numpy will convert different arrays into arrays of the same dimension, broadcasting will be performed on the missing dimension, and the dimension of the array is 1
5. Supplement: Shortcuts for Jupyter Notebook
Jupyter Notebook has two keyboard input modes. Edit mode, which allows you to type code or text into the cell; the cell outline is green. In command mode, the keyboard inputs the command to run the program; the unit frame line is gray at this time.
Command mode (press Esc to open)
- Enter : enter edit mode
- Shift-Enter : run this unit, select the next unit
- Ctrl-Enter : run this unit
- Alt-Enter : run this cell, insert new cell under it
- Y : Unit goes to code state
- M : The unit goes to markdown state
- R : the unit goes to the raw state
- 1 : Set level 1 title
- 2 : Set level 2 title
- 3 : Set level 3 title
- 4 : Set level 4 title
- 5 : Set level 5 heading
- 6 : Set level 6 heading
- Up : select the upper unit
- K : select the upper cell
- Down : select the lower cell
- J : Select the lower unit
- Shift-K : Expand the selected cell above
- Shift-J : Expand the selected cell below
- A : Insert new cell above
- B : Insert new cell below
- X : Cut the selected cell
- C : Copy selected cells
- Shift-V : Paste to cell above
- V : Paste to the cell below
- Z : restore the last unit deleted
- D,D : delete the selected cell
- Shift-M : Merge selected cells
- Ctrl-S : save file to disk
- S : file save
- L : convert line number
- O : Convert output
- Shift-O : Shift output scroll
- Esc : close the page
- Q : close the page
- H : Show shortcut help
- I,I : Interrupt Notebook Kernel
- 0,0 : restart the notebook kernel
- Shift : ignore
- Shift-Space : scroll up
- Space : scroll down
Edit mode (Enter key to start)
- Tab : code completion or indentation
- Shift-Tab : hint
- Ctrl-] : indent
- Ctrl-[ : unindent
- Ctrl-A : select all
- Ctrl-Z : Undo
- Ctrl-Shift-Z : do it again
- Ctrl-Y : do it again
- Ctrl-Home : jump to the beginning of the cell
- Ctrl-Up : jump to the beginning of the cell
- Ctrl-End : jump to the end of the cell
- Ctrl-Down : Jump to the end of the cell
- Ctrl-Left : jump to the left one initial
- Ctrl-Right : jump to the right one prefix
- Ctrl-Backspace : delete the previous word
- Ctrl-Delete : delete the next word
- Esc : enter command mode
- Ctrl-M : enter command mode
- Shift-Enter : run this unit, select the next unit
- Ctrl-Enter : run this unit
- Alt-Enter : run this unit, insert a unit below
- Ctrl-Shift-- : Split cell
- Ctrl-Shift-Subtract : Subtract cells
- Ctrl-S : save file to disk
- Shift : ignore
- Up : Move the cursor up or go to the previous unit
- Down : Move the cursor down or go to the next unit