-
-
Notifications
You must be signed in to change notification settings - Fork 81
SDC Tools Module Sprint 2 #1227
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
Changes from all commits
5d7975d
8d8f293
eff8daf
261b381
afb949e
e4d9711
aa55e33
576a03e
e8a9833
28112fc
93c4886
c4d6658
9c9977c
cb45190
33ee886
fdb7ef0
0368355
34989ef
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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="/" | ||
>}} |
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. | ||
|
||
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>}} |
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 | ||
--> | ||
Comment on lines
+26
to
+28
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Came here to comment this! As it stands, I think this really opens the door to lecturing (which I recognise is unlikely to happen in the first cohort, but long term I think we'll have to defend against). Also, once we've figured out more of a shape of this I'd like to go back to the related prep coursework for this and make it more prescriptive too. |
||
|
||
### 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? |
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. |
Uh oh!
There was an error while loading. Please reload this page.