/
welcome.ipynb.orig
244 lines (244 loc) · 7.12 KB
/
welcome.ipynb.orig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Software Carpentry\n",
"\n",
"# Welcome to Binder\n",
"\n",
"This is where will do all our Python, Shell and Git live coding.\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Jupyter Lab\n",
"\n",
"Let's quickly familiarise ourselves with the enironment ... \n",
"\n",
"- the overal environment (ie your entire browser tab) is called:\n",
"\n",
" *Jupyter Lab*\n",
" \n",
" it contains menus, tabs, toolbars and a file browser\n",
" \n",
"- Jupyter Lab allows you to *launch* files and application into the *Work Area*. Right now you probably have two tabs in the *Work Area* - this document an another tab called *Launcher*.\n",
" \n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Juptyer Notebooks\n",
"\n",
"- this document is document is called an:\n",
"\n",
" *Interactive Python Notebook* (or Notebook for short)\n",
"\n",
"Notebooks are a documents (files) made up of a sequence of *cells* that contain either code (python in our case) or documentation (text, or formatted text called *markdown*).\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Cells\n",
"\n",
"The three types of Cells are:\n",
"\n",
" - *Markdown* - formatted text like this cell (with *italics*, **bold** and tables etc ...)\n",
" - *Raw* - like the following cell, and\n",
" - *Code* - (in our case) python code \n",
"\n",
"Cells can be modified by simply clicking inside them and typing.\n",
"\n",
"See if you can change the cell below by replacing *boring* with something more exciting."
]
},
{
"cell_type": "raw",
"metadata": {},
"source": [
"RAW CELL\n",
"\n",
"This Cell is a 'Raw' Cell - it's just boring text."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Executing Cells\n",
"\n",
"Both *markdown* and *code* cells can be executed.\n",
"\n",
"Excuting a *markdown* causes the *formatted* version of the cell to be displayed. Executing a *code* cell causes the code to run and any results are displayed below the cell.\n",
"\n",
"Any cell can be executed by pressing the play icon at the top of the document while the cell is highlighted.\n",
"\n",
"You can also press **CTL-ENTER** to execute the active cell.\n",
"\n",
"Go ahead and make some more changes to the cells above and execute them - what happens when you execute a *Raw* cell ?"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Adding a Removing Cells\n",
"\n",
"You can use the `+` (plus icon) at the top of the docuement to add a new cell, and use the cell type drop down the change the type.\n",
"\n",
"You can also use the `A` key to add cell *above* the current cell and the `B` key to add *below* the current cell.\n",
"\n",
"\n",
"Now add a couple of cell of your own ..."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**My new Cell in Markdown. Press *scissors* to delete the cell**"
]
},
{
"cell_type": "raw",
"metadata": {},
"source": [
"\n",
"\n",
"see if you can delete this cell - tip, checkout the *Edit* menu ... or even try right-click\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Code Cells\n",
"\n",
"Code cells allow us to write (in our case Python) and run our code and see the results right inside the notebook.\n",
"\n",
"The next cell is a code cell that contains Python code to add 4 numbers.\n",
"\n",
"Try executing the cell and if gets the right result - try some more/different numbers\n"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"15"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"1 + 2 + 3 + 4 + 5"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Let's save our work so for and Push to our changes to GitHub\n",
"\n",
"### Saving\n",
"\n",
"By pressing the save icon on the document (or File -> Save Notebook) we can save our work to our Binder environment.\n",
"\n",
"\n",
"### But what about Version Control and Git (wasn't that in the Workshop syllabus)\n",
"\n",
"Since our binder environment will disappear when we are no longer using is, we need cause our new version to be saved some where permanent.\n",
"\n",
"Luckly we have a GitHub respository already connected to our current environment - however there are couple steps required to make our GitHub repository match the copy of the respository inside our Binder environment.\n",
"\n",
"#### Git likes to know who we are\n",
"\n",
"... otherwise it keeps complaining it cannot track who made what commits (changes).\n",
"\n",
"To tell Git who you are, we need to do the following:\n",
"\n",
"- Launch a Terminal sesson (File -> New -> Terminal, or you can use the *Laucher* tab)\n",
"- At the command prompt, type:\n",
"\n",
"```\n",
"git-setup\n",
"```\n",
" \n",
"This operation only needs to be done once per binder session.\n",
"\n",
"#### Add your changed files to Git's list of files to track\n",
"\n",
"- at the same terminal prompt type:\n",
"\n",
"```\n",
"git add .\n",
"```\n",
" \n",
"#### Tell Git to commit (record) this state as a version\n",
"\n",
"- at the same terminal prompt type: \n",
"\n",
<<<<<<< HEAD
"at this point git has added an additional version of your files to your repository inside your curren Binder environment. However, your repository on GitHub remains unchanged (you might like to go check).\n",
=======
"```\n",
"git commit -m \"save change made inside binder\"\n",
"```\n",
"\n",
"at this point Git has added an additional version of your files to your repository inside your curren Binder environment. However, your repository on GitHub remains unchanges (you might like to go check).\n",
>>>>>>> upstream/master
"\n",
"#### Tell Git to push the new commit (version) to GitHub\n",
"\n",
"- again at the same prompt type:\n",
"\n",
"```\n",
"git push\n",
"```\n",
"\n",
"once you supply the correct GitHub usename and password, all your changes will be *pushed*.\n",
"\n",
"Go check out your respository on github.com ...\n",
"\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}