Skip to content

Commit

Permalink
lecture ready
Browse files Browse the repository at this point in the history
  • Loading branch information
caalo committed Sep 20, 2024
1 parent 44c880e commit 4a908f8
Show file tree
Hide file tree
Showing 6 changed files with 20,603 additions and 288 deletions.
Binary file added images/horst_community.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/horst_community.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
373 changes: 181 additions & 192 deletions slides/lesson1_slides.html

Large diffs are not rendered by default.

151 changes: 55 additions & 96 deletions slides/lesson1_slides.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,17 @@ output-location: fragment

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

## Culture of the course (1/3)
## Culture of the course

. . .

- Challenge: We are learning on the job, but you already have a full-time job
- Challenge: We are learning a new language, but you already have a full-time job

. . .

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

. . .

- *You should understand the gist of the material with class time, but mastery takes practice and practice.*

## Culture of the course (2/3)
## 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.

Expand All @@ -64,105 +60,71 @@ output-location: fragment

. . .

- *You might make a new friend, or two. 😄*

## Culture of the course (3/3)

- Challenge: We all have various personal goals and applications.

. . .

- *Curate content during open community sessions and office hours based on your inputs.*

## Code of Conduct

. . .

- **Be considerate** in speech and actions, and actively seek to acknowledge and respect the boundaries of other members.

. . .

- **Be respectful -** Disagreements happen, but do not require poor behavior or poor manners. If someone asks you to stop, then stop.
- *Know that if you have a question, other people will have it.*

. . .

- **Refrain from demeaning, discriminatory, or harassing behavior and speech**.
- *Asking questions is our way of taking care of others.*

. . .

The full CoC can be found [here](https://github.com/fhdsl/coc).
We ask you to follow [Participation Guidelines](https://hutchdatascience.org/communitystudios/guidelines/) and [Code of Conduct](https://github.com/fhdsl/coc).

## Content of the course

1. Intro to Computing

. . .

2. Data structures

. . .

3. Data wrangling 1

. . .

4. Community Session 1 (optional)

. . .

5. Data wrangling 2

. . .

6. Data visualization

. . .

7. Community Session 2 (optional)

. . .

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

. . .

9. Code-a-thon: Friday Nov. 22

## Format of the course

. . .

- Streamed online, recordings will be available.
- Hybrid, and recordings will be available.

. . .

- 1-2 hour exercises after each session are encouraged for practice.

. . .

- Optional time to work on exercises together on Fridays 10am - 11am PT.
- Office Hours Fridays 10am - 11am PT.

. . .

- Online discussion via Slack.

## What is a computer program?
## Ready?

. . .
![](images/horst_community.png)

- A sequence of instructions to manipulate data for the computer to execute.
## What is a computer program?

. . .

- A series of translations: English \<-\> Programming Code for Interpreter \<-\> Machine Code for Central Processing Unit (CPU)
- A *sequence* of instructions to manipulate data for the computer to execute.

. . .

We will focus on English \<-\> Programming Code for Python Interpreter in this class.
- A series of translations: English \<-\> Programming Code for Interpreter \<-\> Machine Code

. . .

Another way of putting it: **How we organize ideas \<-\> Instructing a computer to do something**.
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!

Expand All @@ -178,17 +140,23 @@ https://forms.gle/zFZ3VB1QZ84Y8Uef6

## Grammar Structure 1: Evaluation of Expressions

Consider the expression:

```{python}
min(2, 10)
```

. . .

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

. . .

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

. . .

- 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.

## Examples

Expand Down Expand Up @@ -250,7 +218,7 @@ add(18, add(21, 65))

![](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 - this emphasizes **abstraction** and **modular** thinking.
- A programmer should not need to know how the function or operation is implemented in order to use it.

. . .

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

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

. . .

To build up a computer program, we need to store our returned data type from our expression somewhere for downstream use.

```{python}
x = 18 + 21
age = 18 + 21
```

. . .
Expand All @@ -284,7 +252,7 @@ Evaluate the expression to the right of `=`.

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

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

::: notes
Expand All @@ -295,86 +263,77 @@ The variable is stored in the working memory of your computer, Random Access Mem

## Downstream

Look, now `x` can be reused downstream:
Look, now `age` can be reused downstream:

```{python}
x - 2
age - 2
```

. . .

```{python}
y = x * 2
y
age_double = age * 2
age_double
```

. . .

What's the data type of a variable?

```{python}
type(y)
type(age_double)
```

## Grammar Structure 3: Evaluation of Functions

A function has a **function name**, **arguments**, and **returns** a data type.
## More examples

::: callout-tip
## Execution rule for functions:
- `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.

A function's input arguments, when there's more than one, can be specified by:
- `pow(base, exp)` takes in two Integer input arguments, and returns the `base` raised to the `exp` power.

- The order the input given: `pow(2, 3)` is different than `pow(3, 2)`.
- `dir()` takes in no input arguments, and returns all the variables in the environment as a list.

- The name of the input argument: `pow(base=2, exp=3)`.

If the arguments contain expressions, evaluate those expressions first!
:::

## Examples
. . .

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

```{python}
pow(base=2, exp=3)
```
. . .

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

. . .

```{python}
max(len("hello"), 4)
dir()
```

## Learning a new function
## Lists

1. Function documentation
**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.

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

pow(base, exp, mod=None)
Equivalent to base**exp with 2 arguments or base**exp % mod with 3 arguments
Some types, such as ints, are able to use a more efficient algorithm when
invoked using the three argument form.
```{python}
chrs = [2, 3, 2, 1, 2]
```

. . .

2. Documents page of a Python Module
Then, you can access the elements of a list via its "index number", starting at 0.

[Base Python documentation of `pow`](https://docs.python.org/3/library/functions.html#pow)
```{python}
chrs[0]
```

. . .

3. Forums vetted by experts, such as [SlackOverflow](https://stackoverflow.com/questions/tagged/pow+python)
```{python}
chrs[1]
```

## Tips on writing your first code

Expand All @@ -394,7 +353,7 @@ Even the smallest spelling and formatting changes will cause unexpected output a

. . .

- Live environments are great for testing, but not great for reproducibility.
- The sequence of instructions you give matters!

. . .

Expand Down
Loading

0 comments on commit 4a908f8

Please sign in to comment.