Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDC Tools Module Sprint 2 #1227

Merged
merged 18 commits into from
Jan 24, 2025
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
17 changes: 11 additions & 6 deletions common-content/en/module/tools/awk/index.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
+++
title = "awk"
headless = true
time = 20
emoji= "💻"
[objectives]
1="Filter a space-separated file and extract a positional field using awk"
2="Sum the numbers in a column of a space-separated file using awk"
3="Explain what NF and $NF mean in awk"
emoji = "💻"
objectives = [
"Filter a space-separated file and extract a positional field using `awk`.",
"Sum the numbers in a column of a space-separated file using `awk`.",
"Explain what `NF` and `$NF` mean in awk.",
]

[build]
list = "local"
publishResources = false
render = "never"
+++

`awk` is a tiny programming language for manipulating columns of data.
Expand Down
45 changes: 45 additions & 0 deletions common-content/en/module/tools/bitwise-operators/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
+++
title = "Bitwise operators"
time = 120
emoji = "📖"
objectives=[
"Describe the meaning of the `&`, `|`, `^`, and `~` bitwise operators.",
"Manually perform the function of the `&`, `|`, `^`, and `~` bitwise operators on two integers.",
]
[build]
list = "local"
publishResources = false
render = "never"
+++

{{<multiple-choice
question="What does the following decimal expression evaluate to?: `9 | 14` (Hint: Convert to binary)"
answers="23 / 15 / 8"
feedback="Not quite - if a bit is set in both numbers, we don't add them. / Right! 1001 | 1110 = 1111 - we take all of the bits that are set in either number. / Not quite - check again what | does."
correct="1"
delimiter="/"
>}}

{{<multiple-choice
question="What does the following decimal expression evaluate to?: `9 & 14` (Hint: Convert to binary)"
answers="16 / 15 / 8"
feedback="Not quite - if a bit is set in both numbers, we don't add them. / Not quite - check again what & does. / Right! 1001 & 1110 = 1000 - we take all of the bits that are set in both numbers."
correct="2"
delimiter="/"
>}}

{{<multiple-choice
question="What does the following decimal expression evaluate to?: `9 ^ 14` (Hint: Convert to binary)"
answers="15 / 7 / 8"
feedback="Not quite - check again what ^ does. / Right! 1001 ^ 1110 = 0111 - we take all of the bits that are set in exactly one of the numbers. / Not quite - check again what ^ does."
correct="1"
delimiter="/"
>}}

{{<multiple-choice
question="What does the following decimal expression evaluate to?: `~9` (Hint: Convert to binary)"
answers="6 / -10 / -9"
feedback="Right! ~1001 flips every bit, which produces 0110 which is 6. / Interesting - how did you come to this answer? If you can't explain why 6 and -10 are both valid answers, learn more about two's complement, truncation, and sign-extension. / Not quite - check again what ~ does."
correct="0"
delimiter="/"
>}}
12 changes: 8 additions & 4 deletions common-content/en/module/tools/cat-1/index.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
+++
title = "cat"
headless = true
time = 10
emoji= "💻"
[objectives]
1="Show the contents of a file with cat"
emoji = "💻"
objectives = [
"Show the contents of a file with `cat`",
]
[build]
list = "local"
publishResources = false
render = "never"
+++

`cat` is a tool for getting the contents of files.
Expand Down
14 changes: 9 additions & 5 deletions common-content/en/module/tools/cat-2/index.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
+++
title = "More cat"
headless = true
time = 10
emoji= "💻"
emoji = "💻"
hide_from_overview = true
[objectives]
1="Show the contents of a file, including line numbers, with cat"
2="Concatenate multiple files outputting to the terminal"
objectives = [
"Show the contents of a file, including line numbers, with `cat`.",
"Concatenate multiple files outputting to the terminal.",
]
[build]
list = "local"
publishResources = false
render = "never"
+++

![Julia Evans' comic about cat](https://wizardzines.com/images/uploads/cat.png)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
+++
title = "Comparing programming languages"
time = 20
emoji = "⚖️"
objectives = [
"Identify whether variables have fixed types in C, Python, and JavaScript.",
"Identify and explain the differences between a function definition in C and Python.",
"Compare compiled and interpreted languages.",
"Explain one advantage of compiled languages, and one advantage of interpreted languages.",
]
[build]
list = "local"
publishResources = false
render = "never"
+++

Variables are names for {{<tooltip text="memory locations" title="Memory location">}}Memory is where we store values. You can think of memory as a long list of locations. Each location can store one byte of data. We can store the byte `0x41` in a memory location. One variable always points at one memory location, but depending on its type may include the data from subsequent memory locations too.{{</tooltip>}}. What's inside the memory location can be changed.

{{<multiple-choice
question="Which languages allow assigning a new value with a different type to a variable."
answers="All programming languages | Only JavaScript | C and Python | JavaScript and Python | C and JavaScript"
feedback="No - some languages require any new value for a variable has the same type as the old value. | JavaScript does allow this, but it isn't the only language to allow it. | No - one of these languages doesn't allow this. | Right - JavaScript and Python are both dynamically typed languages. C is a statically typed language. | No - one of these languages doesn't allow this."
correct="3"
>}}

{{<note type="Exercise">}}
Write the same function twice, once in C and once in Python. The function should take two numbers as parameters, and return the sum of those two numbers.

Write down what's different about the two function definitions.
{{</note>}}

Some programming languages are compiled. Others are interpreted.

{{<note type="Exercise">}}
Write down an explanation of what it means to be compiled or interpreted.
illicitonion marked this conversation as resolved.
Show resolved Hide resolved

List all of the programming languages you know about - is each one compiled or interpreted?

What are the advantages and disadvantages of being compiled or interpreted? Write them down.
{{</note>}}
34 changes: 20 additions & 14 deletions common-content/en/module/tools/cpu-and-memory/index.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,31 @@
+++
title = "CPU and memory"
headless = true
time = 60
emoji= "📖"
[objectives]
1="Explain the purpose of main memory"
2="Explain the purpose of a CPU"
3="Explain what input/output is and why it's useful"
4="Describe the concept of a memory address"
5="Describe how a string is laid out in memory"
6="List (non-exhaustive) examples of instructions that CPUs often support"
7="Define the term 'clock speed' with respect to a CPU"
8="Explain the benefits of CPUs have multiple cores"
9="Describe what CPU cache is, and why one is useful"
10="Explain why computers have secondary storage"
emoji = "📖"
objectives = [
"Explain the purpose of main memory.",
"Explain the purpose of a CPU.",
"Explain what input/output is and why it's useful.",
"Describe the concept of a memory address.",
"Describe how a string is laid out in memory.",
"List (non-exhaustive) examples of instructions that CPUs often support.",
"Define the term 'clock speed' with respect to a CPU.",
"Explain the benefits of CPUs have multiple cores.",
"Describe what CPU cache is, and why one is useful.",
"Explain why computers have secondary storage.",
]
[build]
list = "local"
publishResources = false
render = "never"
+++

Read the learning objectives listed on this page: Bear in mind what you're trying to achieve while reading this text. If a topic isn't making much sense, and isn't in the objectives, you can probably skip over it. If a topic is listed in the objectives, you should keep studying it until you are confident you've met the objective.

{{<note type="Reading">}}
Read chapter 7 of How Computers Really Work.

Do every exercise listed in the chapters.
{{</note>}}

Check you have achieved each learning objective listed on this page.
Check you have achieved each learning objective listed on this page. If you're not sure about any of them, ask in Slack.
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
+++
title = "Discussion: programming language concepts"

time = 60
emoji = "🧰"
objectives = [
"Define the term variable.",
"Explain the purpose of main memory.",
"Describe how a variable relates to a memory location.",
"Describe how a string is laid out in memory.",
"Explain what happens when you call a function.",
"Define the term class.",
"Explain the relationship between a class and an instance of a class.",
"Explain why computers have secondary storage.",
]
[build]
list = "local"
publishResources = false
render = "never"
+++

This sprint you have read about programming language concepts in How Computers Really Work.

Topics to discuss:

<!--
TODO: Make this block more prescriptive about activities
-->

### Variables and memory

What is main memory? What is a variable?

How does a variable relate to a memory location?

How is a string laid out in memory?

How does main memory (RAM) relate to secondary storage (a hard drive)? Why do we have both?

### Functions

What happens when you call a function?

What are parameters/arguments? Return values? Scope?

How does "the next line of code to run" move around when using functions?

### Classes

What is a class? How would you explain a class to someone who doesn't know what code is?

Make sure to discuss real-world examples.

Make sure you describe the relationship between a class and an instance of a class (often called an object).

### Objects

Instances of classes are often called objects.

This kind of "object" is similar to, but slightly different from what we call an "object" in JavaScript.

What are the similarities and differences between these two meanings of the word object?

### CPUs

What does a CPU do?

What benefits are there to having multiple CPU cores?
53 changes: 53 additions & 0 deletions common-content/en/module/tools/grep-in-pipelines/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
+++
title = "grep in pipelines"
time = 20
emoji = "💻"
objectives = [
"List the files in a directory which contain an upper-case letter in their name with `ls` and `grep`.",
"Count the number of files in a directory which contain an upper-case letter in their name with `ls`, `grep`, and `wc`.",
"Explain why we don't need to pass `-1` to `ls` when piping its output.",
]
[build]
list = "local"
publishResources = false
render = "never"
+++

We've already used grep to search for text in files using regular expressions.

We can also pipe other commands' output to `grep` to search the output the same way.

For example, we can write:

```console
% ls -1
report-draft
report-version-1
report-version-1.1
report-version-2
report-final
report-final-2
% ls -1 | grep -v '[0-9]'
report-draft
report-final
```

The original `ls -1` command showed us all the files in the current directory.

By piping this to `grep -v '[0-9]'` we can filter this output down to just the files whose names don't contain numbers.

`grep` operates on lines, and `ls -1` outputs one file per line, so `grep` tests each file one at a time.

### `ls` vs `ls -1`

In our terminal, when we run `ls -1`, we get one file output per line. But if we run `ls` in our terminal, we get the files on one line, separated by spaces.

We know that `grep` operates on individual lines, so it may seem like `ls | grep` would have a problem - `ls` prints more than one file per line.

But `ls` behaves specially. It detects whether it's outputting to a terminal, or a pipe, and acts differently:
* If it's outputting to a pipe, it outputs one file per line.
* If it's outputting to a terminal, it tries to be useful and take up less space. But if you pass `-1` it will _force_ `ls` to output one file per line.

So we can write `ls | grep -v '[0-9]'` - we don't need to pass `-1` to `ls`.

It's good to know that sometimes programs behave differently when outputting to a terminal or a pipeline.
14 changes: 9 additions & 5 deletions common-content/en/module/tools/grep/index.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
+++
title = "grep"
headless = true
time = 30
emoji= "💻"
[objectives]
1="Identify the lines in a file which contain a string using grep"
2="Identify which files contain a string using grep"
emoji = "💻"
objectives = [
"Identify the lines in a file which contain a string using `grep`",
"Identify which files contain a string using `grep`",
]
[build]
list = "local"
publishResources = false
render = "never"
+++

`grep` is a tool for searching files for text.
Expand Down
Loading
Loading