Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions 01-intro-to-computing.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ Now, we will get to the basics of programming grammar.

- **Expressions** are be built out of **operations** or **functions**.

- Functions and operations take in **data types** as inputs, do something with them, and **return** another data type as ouput.
- Functions and operations take in **data types** as inputs, do something with them, and **return** another data type as output.

- We can combine multiple expressions together to form more complex expressions: an expression can have other expressions nested inside it.
- If the function or operation input contains expressions, evaluate those expressions first.

For instance, consider the following expressions entered to the Python Console:

Expand Down Expand Up @@ -222,7 +222,7 @@ And there is an operational equivalent:
We will mostly look at functions with input arguments and return types in this course, but not all functions need to have input arguments and output return. Let's look at some examples of functions that don't always have an input or output:

| Function call | What it takes in | What it does | Returns |
|---------------------------------------------------------------------------|--------------------------|---------------------------------------------------------------|---------|
|-----------------------|----------------|------------------|----------------|
| [`pow(a, b)`](https://docs.python.org/3/library/functions.html#pow) | integer `a`, integer `b` | Raises `a` to the `b`th power. | Integer |
| [`time.sleep(x)`](https://docs.python.org/3/library/time.html#time.sleep) | Integer `x` | Waits for `x` seconds. | None |
| [`dir()`](https://docs.python.org/3/library/functions.html#dir) | Nothing | Gives a list of all the variables defined in the environment. | List |
Expand Down
2 changes: 1 addition & 1 deletion 02-data-structures.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ The list data structure we have been working with is an example of an **Object**

- **Attributes** that hold subset or additional data for the object.

- Functions called **Methods** that are for the object and *have to* take in the variable referenced as an input
- Functions called **Methods** that are for the object and *have to* take in the variable referenced as an input.

This organizing structure on an object applies to pretty much all Python data types and data structures.

Expand Down
Binary file added images/Intro_to_Python_R2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/stickers mosaic.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions index.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ The course is intended for researchers who want to learn coding for the first ti

## Learning Objectives

**Analyze** Tidy datasets in the Python programming language via data subsetting, joining, and transformations.
- **Analyze** Tidy datasets in the Python programming language via data wrangling, summary statistics, and visualization.

**Evaluate** summary statistics and data visualization to understand scientific questions.
- **Compute** summary statistics and create data visualizations to interpret data.

**Describe** how the Python programming environment interpret complex expressions made out of functions, operations, and data structures, in a step-by-step way.
- **Describe** how the Python programming environment interpret complex expressions made out of functions, operations, and data structures, in a step-by-step way.

**Apply** problem solving strategies to debug broken code.
- **Apply** problem solving strategies to debug broken code.

## Offerings

Expand Down
4 changes: 4 additions & 0 deletions slides/examples/ex1.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
a,b,c,d,message
1,2,3,4,hello
5,6,7,8,world
9,10,11,12,foo
3 changes: 3 additions & 0 deletions slides/examples/ex2.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
1,2,3,4,hello
5,6,7,8,world
9,10,11,12,foo
7 changes: 7 additions & 0 deletions slides/examples/ex3.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# hey!
a,b,c,d,message
# just wanted to make things more difficult for you
# who reads CSV files with computers, anyway?
1,2,3,4,hello
5,6,7,8,world
9,10,11,12,foo
Binary file added slides/images/Intro_to_Python_R2-01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added slides/images/Intro_to_Python_R2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added slides/images/Intro_to_Python_Square.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added slides/images/gator_error.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added slides/images/join-01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added slides/images/join-02.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added slides/images/join-03.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added slides/images/join.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added slides/images/stickers mosaic.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
475 changes: 201 additions & 274 deletions slides/lesson1_slides.html

Large diffs are not rendered by default.

172 changes: 74 additions & 98 deletions slides/lesson1_slides.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,25 @@
title: "W1: Intro to Computing"
format:
revealjs:
smaller: false
smaller: true
scrollable: true
echo: true
output-location: fragment
---

## Welcome!

![](images/Intro_to_Python_R2-01.png){width="600"}

Please sign up for Google Classroom ([link](https://classroom.google.com/c/NzY0OTY2Nzc0NzU5?cjc=wpplaqbt)) if you haven't already.

## Introductions

- Who am I?

. . .

- What is DaSL?
- What is [DaSL](https://hutchdatascience.org/)?

. . .

Expand All @@ -26,7 +30,13 @@ output-location: fragment

- What you want to get out of the class

- Favorite fall activity
- What is a favorite springtime activity?\

. . .

- Our wonderful TAs!

##

## Goals of the course

Expand All @@ -40,6 +50,20 @@ output-location: fragment

![Data science workflow](https://d33wubrfki0l68.cloudfront.net/571b056757d68e6df81a3e3853f54d3c76ad6efc/32d37/diagrams/data-science.png){width="550"}

## Content of the course

1. Intro to Computing

2. Data structures

3. Data wrangling 1

4. Data wrangling 2

5. Data visualization

6. Wrap-up

## Culture of the course

. . .
Expand All @@ -50,63 +74,59 @@ output-location: fragment

- *Teach not for mastery, but teach for empowerment to learn effectively.*

## Culture of the course

- Challenge: We sometimes struggle with our data science in isolation, unaware that someone two doors down from us has gone through the same struggle.

. . .

- *We learn and work better with our peers.*
- *Teach at learner's pace.*

. . .
## Culture of the course

- *Know that if you have a question, other people will have it.*
- Challenge: We sometimes struggle with our data science in isolation, unaware that someone two doors down from us has worked on something similar.

. . .

- *Asking questions is our way of taking care of others.*
- *We learn and work better with our peers.*

. . .

We ask you to follow [Participation Guidelines](https://hutchdatascience.org/communitystudios/guidelines/) and [Code of Conduct](https://github.com/fhdsl/coc).
- *We encourage discussion and questions, as others often have similar questions also.*

## Content of the course
## Format of the course

1. Intro to Computing
. . .

2. Data structures
- Hybrid, and recordings will be available.

3. Data wrangling 1
. . .

4. Community Session 1 (optional)
- 1 hour exercises after each session are encouraged for practice.

5. Data wrangling 2
. . .

6. Data visualization
- Office Hours Mondays Noon-1pm

7. Community Session 2 (optional)
. . .

8. Putting it together: preview for code-a-thon (Tuesday Nov. 12)
## Badge of completion

9. Code-a-thon: Friday Nov. 22
![](images/Intro_to_Python_Square.png){width="350"}

## Format of the course
We offer a [badge of completion](https://www.credly.com/org/fred-hutch/badge/intro-to-python) when you finish the course!

. . .
What it is:

- Hybrid, and recordings will be available.
- A display of what you accomplished in the course, shareable in your professional networks such as LinkedIn, similar to online education services such as Coursera.

. . .
What it isn't:

- 1-2 hour exercises after each session are encouraged for practice.
- Accreditation through an university or degree-granting program.

. . .

- Office Hours Fridays 10am - 11am PT.
Requirements:

. . .
- Complete badge-required sections of the exercises for 4 out of 5 assignments.

- Online discussion via Slack.
##

## Ready?

Expand All @@ -120,23 +140,25 @@ We ask you to follow [Participation Guidelines](https://hutchdatascience.org/com

. . .

- A series of translations: English \<-\> Programming Code for Interpreter \<-\> Machine Code
- A series of *translations*: English \<-\> Programming Code for Interpreter \<-\> Machine Code

. . .

We will focus on English \<-\> Programming Code for Python Interpreter in this class.

## Setting up Google Classroom and Colab and trying out your first analysis!

- Google Classroom [invitation link](https://classroom.google.com/c/NzAyODI5NzU1NDU4?cjc=nq7lioy).
- Google Classroom invite: <https://classroom.google.com/c/NzY0OTY2Nzc0NzU5?cjc=wpplaqbt>

- Classwork -\> Week 1 Classwork -\> `Week 1 Classwork.ipynb`

- Alternative link [here](https://colab.research.google.com/drive/1_77QQcj0mgZOWLlhtkZ-QKWUP1dnSt-_?authuser=1#scrollTo=vSuAhvp2Aa33).

## Break

A pre-course survey:

https://forms.gle/zFZ3VB1QZ84Y8Uef6
<https://forms.gle/3rJvTEhwJfH95raf8>

## Grammar Structure 1: Evaluation of Expressions

Expand All @@ -152,7 +174,7 @@ min(2, 10)

. . .

- Functions and operations take in **data types** as inputs, do something with them, and **return** another data type as ouput.
- Functions and operations take in **data types** as inputs, and **return** another data type as output.

. . .

Expand Down Expand Up @@ -188,37 +210,11 @@ max(18 + 21, 65)
len("ATCG")
```

::: notes
If an expression is made out of multiple, nested operations, what is the proper way of the Python Console interpreting it? Being able to read nested operations and nested functions as a programmer is very important.
:::

## Function machine from algebra class

. . .

![](images/function_machine.png){alt="Function machine from algebra class."}
## Interpreting functions

. . .

Operations are just functions. We could have written:
![](https://moffett4understandingmath.com/wp-content/uploads/2017/06/function-machine.png){alt="Function machine from algebra class." width="200"}

```{python}
from operator import add

add(18, 21)
```

. . .

```{python}
add(18, add(21, 65))
```

## Function machine from algebra class

![](images/function_machine.png){alt="Function machine from algebra class."}

- A programmer should not need to know how the function or operation is implemented in order to use it.
- To use a function, we only need to know what the expected inputs and outputs are. The inner workings don't matter yet.

. . .

Expand All @@ -233,7 +229,7 @@ add(18, add(21, 65))
| String | str | "hello", "234-234-8594" |
| Boolean | bool | True, False |

## Grammar Structure 2: Storing data types as variables in the environment
## Grammar Structure 2: Storing variables in the environment

. . .

Expand All @@ -245,21 +241,11 @@ age = 18 + 21

. . .

::: callout-tip
## Execution rule for variable assignment

Evaluate the expression to the right of `=`.

Bind variable to the left of `=` to the resulting value.
Bind variable on the left of `=` to the resulting value.

The variable is stored in the **environment**.
:::

::: notes
The environment is where all the variables are stored, and can be used for an expression anytime once it is defined. Only one unique variable name can be defined.

The variable is stored in the working memory of your computer, Random Access Memory (RAM). This is temporary memory storage on the computer that can be accessed quickly. Typically a personal computer has 8, 16, 32 Gigabytes of RAM. When we work with large datasets, if you assign a variable to a data type larger than the available RAM, it will not work. More on this later.
:::
Then the variable is stored in the **environment**.

## Downstream

Expand All @@ -284,36 +270,32 @@ What's the data type of a variable?
type(age_double)
```

## More examples
## More practice

- `max(a, b, ...)` takes in at least two Integer or Float input arguments, and returns the highest value. You can give it more than two input arguments.
- `max(a, b, ...)` takes in at least two numeric input arguments, and returns the highest value.

- `pow(base, exp)` takes in two Integer input arguments, and returns the `base` raised to the `exp` power.

- `dir()` takes in no input arguments, and returns all the variables in the environment as a list.

. . .

```{python}
max(len("hello"), pow(2, 3), 20)
(len("hello") + 4) * pow(2, 3)
```

. . .

```{python}
age = 35 - 5
score = max(age, pow(2, 3), 20)
```

. . .

```{python}
dir()
brothers_age = 45
grandmas_age = 90
cousins_age = 32
age = max(cousins_age, brothers_age, grandmas_age)
secret = (len("hello") + age) * pow(2, 3)
secret
```

## Lists

**List** is a data structure that stores many elements of various data type, and the order its elements are stored matters. Each *element* of a List contains a single data type, or single data structure.
**List** is a **data structure** that stores many elements of various data type, and the order its elements are stored matters.

You can create a List via the bracket \`\[ \]\` operator:

Expand Down Expand Up @@ -341,19 +323,13 @@ chrs[1]

`Computer = powerful + stupid`

Even the smallest spelling and formatting changes will cause unexpected output and errors!

. . .

- Write incrementally, test often

. . .

- Check your assumptions, especially using new functions, operations, and new data types.
- Write incrementally: if `function(a, b + c)` isn't working, examine `a` and `b + c`

. . .

- The sequence of instructions you give matters!
- The sequence of instructions you give matters! Refresh the page to clear the environment.

. . .

Expand Down
Loading