Skip to content

Commit 67cc93a

Browse files
committed
Cleaned up lesson 02
1 parent 5d4b987 commit 67cc93a

6 files changed

Lines changed: 606 additions & 625 deletions

File tree

docs/lessons/02_variables.html

Lines changed: 502 additions & 571 deletions
Large diffs are not rendered by default.

docs/schedule/schedule.qmd

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,4 +162,37 @@ II. **Submit your work**:
162162

163163
## Resources
164164

165-
- [Introduction to data analysis in Python](https://ccb-hms.github.io/workbench-python-workshop/index.html)
165+
### Popular package resources
166+
167+
For a brief overview, or cheat sheet, of the most commonly used Python packages in data analysis, check out the following resources:
168+
169+
- [Pandas cheat sheet](https://pandas.pydata.org/Pandas_Cheat_Sheet.pdf)
170+
- [NumPy cheat sheet](https://www.datacamp.com/cheat-sheet/numpy-cheat-sheet-data-analysis-in-python)
171+
- [Matplotlib cheat sheet](https://matplotlib.org/cheatsheets/cheatsheets.pdf)
172+
- [Scikit-learn cheat sheet](https://www.datacamp.com/cheat-sheet/scikit-learn-cheat-sheet-python-machine-learning)
173+
- [Seaborn examples with code](https://seaborn.pydata.org/examples/index.html)
174+
175+
176+
### Other Python courses
177+
178+
We acknowledge that there are many other groups that have created excellent Python courses:
179+
180+
- [Harvard CCB - Introduction to Data Analysis in Python](https://ccb-hms.github.io/workbench-python-workshop/index.html)
181+
- [Google - Python Class](https://developers.google.com/edu/python)
182+
- [Coursera - Python for Everybody](https://www.coursera.org/specializations/python)
183+
184+
185+
### Learning more AI and ML
186+
187+
Python is one of the most popular languages for machine learning and artificial intelligence. If you are interested in learning more about these topics, we recommend the following resources as good starting points:
188+
189+
- [Coursera - Machine Learning by Andrew Ng](https://www.coursera.org/learn/machine-learning)
190+
- [fast.ai - Practical Deep Learning for Coders](https://course.fast.ai/)
191+
192+
193+
### Datasets for more practice
194+
195+
There are many websites that aggregate interesting datasets that you can use to practice your Python skills. Here are a few popular ones:
196+
197+
- [kaggle](https://www.kaggle.com/datasets)
198+
- [Hugging Face](https://huggingface.co/datasets)

docs/schedule/self-learning.qmd

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,37 @@ Once downloaded, run the installer and follow the prompts to complete the instal
3636

3737
## Resources
3838

39-
- [Additional Resource 1](link_to_additonal_resource_1)
40-
- [Additional Resource 2](link_to_additonal_resource_2)
41-
- [Additional Resource 3](link_to_additonal_resource_3)
39+
### Popular package resources
40+
41+
For a brief overview, or cheat sheet, of the most commonly used Python packages in data analysis, check out the following resources:
42+
43+
- [Pandas cheat sheet](https://pandas.pydata.org/Pandas_Cheat_Sheet.pdf)
44+
- [NumPy cheat sheet](https://www.datacamp.com/cheat-sheet/numpy-cheat-sheet-data-analysis-in-python)
45+
- [Matplotlib cheat sheet](https://matplotlib.org/cheatsheets/cheatsheets.pdf)
46+
- [Scikit-learn cheat sheet](https://www.datacamp.com/cheat-sheet/scikit-learn-cheat-sheet-python-machine-learning)
47+
- [Seaborn examples with code](https://seaborn.pydata.org/examples/index.html)
48+
49+
50+
### Other Python courses
51+
52+
We acknowledge that there are many other groups that have created excellent Python courses:
53+
54+
- [Harvard CCB - Introduction to Data Analysis in Python](https://ccb-hms.github.io/workbench-python-workshop/index.html)
55+
- [Google - Python Class](https://developers.google.com/edu/python)
56+
- [Coursera - Python for Everybody](https://www.coursera.org/specializations/python)
57+
58+
59+
### Learning more AI and ML
60+
61+
Python is one of the most popular languages for machine learning and artificial intelligence. If you are interested in learning more about these topics, we recommend the following resources as good starting points:
62+
63+
- [Coursera - Machine Learning by Andrew Ng](https://www.coursera.org/learn/machine-learning)
64+
- [fast.ai - Practical Deep Learning for Coders](https://course.fast.ai/)
65+
66+
67+
### Datasets for more practice
68+
69+
There are many websites that aggregate interesting datasets that you can use to practice your Python skills. Here are a few popular ones:
70+
71+
- [kaggle](https://www.kaggle.com/datasets)
72+
- [Hugging Face](https://huggingface.co/datasets)

docs/search.json

Lines changed: 26 additions & 15 deletions
Large diffs are not rendered by default.

lessons/01_setting_up.qmd

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,6 @@ We will start by calculating the sum of 3 and 5. We are also going to include **
241241
# April 2026
242242
# Author: Harvard Chan Bioinformatics Core
243243
244-
245244
# Add 3 and 5
246245
3 + 5
247246
```

lessons/02_variables.qmd

Lines changed: 10 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ When creating variables in Python, there are some rules and guidelines that you
6969
There is an [official Python style guide](https://peps.python.org/pep-0008/) that has much more detailed guidelines.
7070
:::
7171

72-
If we would like to see the value of a variable we have created, we can use the the `print()` function:
72+
If we would like to see the value of a variable we have created, we can call the variable name:
7373

7474
```{python}
7575
#| label: show_my_number
@@ -87,28 +87,23 @@ Another way you can print a variable is by putting it within a `print()` functio
8787
print(my_number)
8888
```
8989

90-
Putting variables within `print()` function can be very helpful in case you want to inspect multiple variables. We will see this shortly. You can also add text around a variable within the `print()` function:
90+
We can also print entire messages that include variables by putting the variable within the `print()` function. When we add text around a variable, it automatically adds spaces on either side of that variable inside the `print()` function.
9191

9292
```{python}
9393
#| label: text_within_print
9494
# Added text within the print function
9595
print('I want to remember', my_number, 'for later use.')
9696
```
9797

98-
::: {.callout-note}
99-
# The `print()` function
100-
You can see that when we add text around a variable, it automatically adds spaces on either side of that variable inside the `print()` function.
101-
:::
102-
103-
Let's go ahead and create a second number that we are interested in:
98+
Now let us create a second variable that we are interested in. We can assign it a different value and continue to investigate variables and the `print()` fucntion.
10499

105100
```{python}
106101
#| label: create_variable_2
107102
# Creating a second variable called your_number
108103
your_number = 8.5
109104
```
110105

111-
We can use the `print()` function to see the values of these variables:
106+
Putting variables within `print()` function can be very helpful in case you want to inspect _multiple variables_. We can use the `print()` function to see the values of these variables:
112107

113108
```{python}
114109
#| label: multiple_variable_within_print
@@ -131,7 +126,7 @@ Do you notice that it only has the output from `your_number`? This is because wi
131126

132127
```{python}
133128
#| label: with_print
134-
# Print my number
129+
# Print my_number
135130
print(my_number)
136131
137132
# Print your_number
@@ -147,6 +142,7 @@ f-strings (formatted string literals) are a concise way to build strings (text v
147142
# f-string Example
148143
print(f'I want to remember {my_number} and {your_number}')
149144
```
145+
150146
:::
151147

152148
You can carry out basic arithmetic using variables. For example, if we wanted to add `my_number` and `your_number`, we could do that with:
@@ -252,6 +248,7 @@ difference = a - b
252248
#| echo: false
253249
print('The difference of', a, 'and', b, 'is', difference)
254250
```
251+
255252
:::
256253

257254
## Types of variables
@@ -290,30 +287,9 @@ Integers are whole numbers and floats are numbers with decimals. Both of these d
290287
5 + 3.14
291288
```
292289

293-
::: {.callout-note collapse="true"}
294-
# You do not always have to `print()` your variables
295-
You can directly see the output for a variable to if you run a cell and the variable is the last line in the code chunk. However, this will ony work for seeing on variable at a time, so if you wanted to see two variables as the same time, we would have to use the print function. For example:
296-
297-
```{python}
298-
#| label: print_example_1
299-
our_sum
300-
my_number
301-
```
302-
303-
versus
304-
305-
```{python}
306-
#| label: print_example_2
307-
print(our_sum)
308-
print(my_number)
309-
```
310-
311-
:::
312-
313-
314290
### Strings
315291

316-
Strings are a data type that can hold a sequence of characters. Strings are denoted by wrapping the string in either single- or double-quotes and either is acceptable.
292+
Strings are a data type that can hold a sequence of characters. Strings are denoted by wrapping the string in either single(`''`)- or double-quotes(`""`). Both are allowed in Python.
317293

318294
```{python}
319295
#| label: string_variable
@@ -445,12 +421,12 @@ print(type(True + True + False))
445421
If we right click on some empty space within the JupyterLab interface, we can open up the `Variable Inspector`. This is a helpful tool to see all of the variables that you have created and their data types.
446422

447423
::: {#fig-jupyter_right_click .figure}
448-
![](../img/jupyter_lab_right_click.png)
424+
![](../img/jupyter_lab_right_click.png){width="50%"}
449425

450426
Options after right-clicking an empty spot within JupyterLab.
451427
:::
452428

453-
Once we open up the `Variable Inspector`, a new tab will open. From this tab, we can see all of the variables that we have created, their data types and their values. This is a useful resource to quickly check what variables you have created and what they contain, especially if you have created many variables and cannot recall what each are.
429+
Once we open up the Variable Inspector, a new tab will open. From this tab, we can see all of the variables that we have created, their data types and their values. This is a useful resource to quickly check what variables you have created and what they contain, especially if you have created many variables and cannot recall what each are.
454430

455431

456432
::: {#fig-jupyter_variable_inspector .figure}

0 commit comments

Comments
 (0)