Skip to content

Commit e3bb8bb

Browse files
committed
initialize intro notebook
1 parent a172a4d commit e3bb8bb

File tree

1 file changed

+84
-0
lines changed

1 file changed

+84
-0
lines changed

02.python-intro/python-intro.ipynb

+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"id": "f278ac8d-1a6a-4ac7-aa5a-aa5056968ec0",
6+
"metadata": {},
7+
"source": [
8+
"# intro to python\n",
9+
"\n",
10+
"## overview\n",
11+
"\n",
12+
"Programming is a powerful tool that allows us to do complicated calculations and analysis, visualize data, and automate workflows to ensure consistency, accuracy, and reproducibility in our research.\n",
13+
"\n",
14+
"In this exercise, you will get a basic introduction to the python programming language, including variables and objects, data types, and how to control the flow of our programs. Over the next few sessions, we will build on these ideas, using some real example data, to get more of an idea of how to use python in our research.\n",
15+
"\n",
16+
"This is an interactive notebook - in between bits of text, there are interactive cells which you can use to execute snippets of python code. To run these cells, highlight them by clicking on them, then press CTRL and ENTER (or SHIFT and ENTER, or by pressing the \"play\" button at the top of this tab).\n",
17+
"\n",
18+
"## objectives\n",
19+
"\n",
20+
"After finishing this exercise, you will:\n",
21+
"\n",
22+
"- learn and gain experience with some of the basic elements of python and programming\n",
23+
"- learn how to use the python command line interface\n",
24+
"\n",
25+
"\n",
26+
"## objects and assignment\n",
27+
"\n",
28+
"We'll start by creating a new object, foo, and assigning it a value of `hello, world!`:\n",
29+
"\n",
30+
"```python\n",
31+
"\n",
32+
" foo = \"hello, world!\" # assign an object using =\n",
33+
"\n",
34+
"```\n",
35+
"\n",
36+
"In the text above (and the cell below), you should notice that the color of different parts of the text is different. We'll discuss different aspects of this as we go, but pay attention to the greenish text that comes after the `#` - this indicates a *comment*, meaning text that is intended for humans to read, but that is ignored by the python interpreter. We'll discuss comments more when we start looking at writing scripts, but as you work through the exercises, make sure to read the comments - they're there to help you understand what each line of code actually does.\n",
37+
"\n",
38+
"After creating the `foo` **object**, we use the built-in `print()` ([documentation](https://docs.python.org/3/library/functions.html#print)) function (more on these later) to see the *value* of that object. \n",
39+
"\n",
40+
"Go ahead and run the cell to get started:"
41+
]
42+
},
43+
{
44+
"cell_type": "code",
45+
"execution_count": null,
46+
"id": "0d6b074f-13d3-4e6c-980d-9d56f90f8fe1",
47+
"metadata": {},
48+
"outputs": [],
49+
"source": [
50+
"foo = \"hello, world!\" # assign an object using =\n",
51+
"print(foo) # print the value of the object to the screen"
52+
]
53+
},
54+
{
55+
"cell_type": "code",
56+
"execution_count": null,
57+
"id": "924bdfc6-e229-48c3-81c1-f80e37a8829e",
58+
"metadata": {},
59+
"outputs": [],
60+
"source": []
61+
}
62+
],
63+
"metadata": {
64+
"kernelspec": {
65+
"display_name": "Python 3 (ipykernel)",
66+
"language": "python",
67+
"name": "python3"
68+
},
69+
"language_info": {
70+
"codemirror_mode": {
71+
"name": "ipython",
72+
"version": 3
73+
},
74+
"file_extension": ".py",
75+
"mimetype": "text/x-python",
76+
"name": "python",
77+
"nbconvert_exporter": "python",
78+
"pygments_lexer": "ipython3",
79+
"version": "3.11.6"
80+
}
81+
},
82+
"nbformat": 4,
83+
"nbformat_minor": 5
84+
}

0 commit comments

Comments
 (0)