Download the course content Lectures and Exercises as ZIP files. Unpack them and place the folders wherever you want them on your computer.
Open VSCode
Use File → Open Folder and locate the folder containing the lectures
Use File → Add Folder to Workspace and locate the folder containing the exercies
Check that both folders appear in the Explorer panel on the left.
(Optional) Try File → Save Workspace As ... and later File → Open Workspace From File
Windows: Press Ctrl+Shift+P to command control palette
Mac: Cmd⌘+Shift+P
Paste in Python: Select Interpreter, choose the option where anaconda3 is part of the path
Paste in Jupyter: Select Interpreter to Start Jupyter Server, choose the same path as above
In the lectures folder open the file 01_Introduction/Introduction.ipynb
Note: You might see a pop-up asking you to choose an interpreter or kernel. Again, choose the same path as above.
Scroll to the first code cell. Run with Shift+Enter
Explanation: Jupyter is a Python package for running notebooks. In the first step above, you specify which Python installation VS Code should use in general. In the second step, you specify which Python installation should be used for running notebooks. These should be the same. The Python environment used by a notebook is also called its kernel. You can see the selected kernel in the upper-right corner of the editor window.
Note: You might have other Python installations that were installed automatically by other programs. You can simply leave them as they are.
Use File → New File and choose Jupyter Notebook.
Write some code and run it with Shift+Enter
Save the notebook using File → Save
To write code efficiently, it is beneficial to know a lot of short cuts. Below are the most important commands to know and the associated keys on a Danish Windows computer.
If you are using a Mac the short cuts typically changes with Ctrl → Cmd⌘ and Alt → Opt⌥ .
You see all keybindings in VSCode for your computer pressing:
Windows: Ctrl+K, Ctrl+S
Mac: Cmd⌘+K, Cmd⌘+S
Command control palette: Ctrl+Shift+P
Use short-cuts for changing view:
New window: Ctrl+N
Open window: Ctrl+O
Close window: Ctrl+F4
Toggle window: Ctrl+tab
Next/previous windows Ctrl+PgUp/PgDn
Open/close sidebar: Ctrl+B
Open/close alternative sidebar: Ctrl+Alt+B
Open/close panel: Ctrl+J
Open explorer: Ctrl+Shift+E
Open source control: Ctrl+Shift+G
Open extensions: Ctrl+Shift+X
See problems: Ctrl+Shift+M
Go to next problem: F8
Locate symbol: Ctrl+Shift+O
Go to symbol: F12 (just peak Alt+F12)
Go to line: Ctrl+G
Zoom: Ctrl++ / Ctrl+-
Zen mode: Ctrl+K,Z
Save file: Ctrl+S
Change settings? Ctrl+,
Change short cuts? Ctrl+K, Ctrl+S
Use smart short cuts for editing:
Move current line: Alt+↑ / ↓
Copy current line: Alt+Shift+↑ / ↓
Cut current line: Ctrl+X
Indent line: Tab
Deindent line: Shift+Tab
Fold/unfold:
single block: Ctrl+Shift+´ / Ctrl+Shift+å
all: Ctrl+K, Ctrl+1 / Ctrl+K, Ctrl+J
Toggle commment: Ctrl+'
Select multiple occurances: Ctrl+D (undo: Ctrl+U)
Select columns: Ctrl+Shift+Alt
When inside a cell you are in edit mode, when not you are in command mode.
The most important notebook commands are:
Run cell: Ctrl+Enter
Run cell and advance: Shift+Enter
Enter edit mode: Enter
Exit edit mode: Esc
Only in command mode:
Change to markdown cell: M
Change to code cell: Y
Create cell above: A
Create cell belove: B
Delete cell: D+D
Move cell up: Alt+PgUp
Move cell up: Alt+PgUp
Split cell: Ctrl+Shift+-
Copy cell: Ctrl+C
Paste cell: Ctrl+V
Markdown: Guide on writing markdown
If is beneficial to able to clear a notebook and re-run it from start to end. This require three steps:
Clear all outputs
Restart
Run all
You can create a short-cut to do this all at once with Ctrl+Space following this:
Open extensions Ctrl+Shift+X
Search for and install multi-command
Press Ctrl+Shift+P
Use Preferences: Open Keyboard Shortcuts (JSON)
Paste in and save
{
"key": "ctrl+space",
"command": "extension.multiCommand.execute",
"args": {
"sequence": [
"notebook.clearAllCellsOutputs",
"jupyter.restartkernel",
"notebook.execute"
]
},
"when": "notebookEditable && activeEditor == 'workbench.editor.notebook'"
}