Skip to content

Commit

Permalink
Review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
illicitonion committed Dec 23, 2024
1 parent c539263 commit dc98c37
Show file tree
Hide file tree
Showing 6 changed files with 137 additions and 30 deletions.
43 changes: 43 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,43 @@
+++
title = "Bitwise operators"
headless = true
time = 120
facilitation = false
emoji= "📖"
objectives=[
"Describe the meaning of the &, |, ^, and ~ bitwise operators.",
"Manually perform the function of the &, |, ^, and ~ bitwise operators on two integers.",
]
+++

{{<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,38 @@
+++
title = "Comparing programming languages"
headless = true
time = 20
facilitation = false
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.",
]
+++

Variables are names for memory locations. 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>}}
2 changes: 1 addition & 1 deletion common-content/en/module/tools/head-and-tail/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Imagine we have an input file which has 100 lines.

{{<multiple-choice
delimiter="~"
question="What command could we write to skip the first three lines of the file, and then output the next 2 lines?"
question="What command/pipeline could we write to skip the first three lines of the file, and then output the next 2 lines?"
answers="head -n3 input | tail -n2 ~ tail -n+4 | head -n2 ~ tail -n+3 | head -n2"
feedback="No - remember each stage in a pipeline applies to the output of the previous stage, not the original file. ~ Right - tail skips the first few lines, then head takes just a few from the top of that output. ~ Not quite - how many lines does this skip?"
correct="1" >}}
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,57 @@ headless = true
time = 120
facilitation = false
emoji= "📖"
[objectives]
1="Describe what a variable is."
2="Describe how a variable relates to a memory location."
3="Identify whether variables have fixed types in C, Python, and JavaScript."
4="Explain how the next memory location is found when declaring a local variable on the stack."
5="Explain why some variables are allocated on the heap not the stack."
6="Explain when memory used for a variable on the stack is released."
7="Explain when memory used for a variable on the heap is released."
8="Define an operator."
9="Give examples of common operators."
10="Explain the difference between integer division and floating point division."
11="Describe the meaning of the &, |, ^, and ~ bitwise operators."
12="Manually perform the function of the &, |, ^, and ~ bitwise operators on two integers."
13="Describe the meaning of the && (and), || (or), and ! (not) operators."
14="Explain when it's more appropriate to use a while loop or a for loop."
15="Identify and explain the differences between a function definition in C and Python."
16="Explain what happens when you call a function."
17="Explain what a class is."
18="Describe the relationship between an object and a class."
19="Compare compiled and interpreted languages."
20="Explain one advantage of compiled languages, and one advantage of interpreted languages."
objectives=[
"Describe what a variable is.",
"Describe how a variable relates to a memory location.",
"Give examples of common operators.",
"Describe the meaning of the && (and), || (or), and ! (not) operators.",
"Explain what happens when you call a function.",
]
+++

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 9 of How Computers Work.

Do every exercise listed in the chapters.
Do every exercise listed in the chapter.

You can skip the projects (though you're welcome to try any of them if you have time!).
{{</note>}}

Check you have achieved each learning objective listed on this page.

{{<note type="Exercise">}}
Write down an explanation of what a variable is. Make sure to use the term "memory location" in your explanation.
{{</note>}}

{{<note type="Exercise">}}
Write down what operators you have used in a programming language.

Next to each, write down whether it's a unary, binary, or ternary operator.

Make sure you have at least one example of a unary operator, a binary operator, and a ternary operator.
{{</note>}}

{{<note type="Exercise">}}
Write down what happens when you call a function.

Make sure you include how the "next line of code to run" moves around, parameters/arguments, return values, and scope.
{{</note>}}

{{<note type="Exercise">}}
Write down an explanation of what a class is, which could be understood by someone who's never written any code before.

Include at least one real-world example of when a class is useful.

Make sure you describe the relationship between a class and an instance of a class.
{{</note>}}

{{<note type="Exercise">}}
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.

Write down the differences between the two meanings of the word object.
{{</note>}}
12 changes: 6 additions & 6 deletions common-content/en/module/tools/sort-and-uniq/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ time = 20
facilitation = false
emoji= "💻"
[objectives]
1="Count the occurences of different lines within a file using sort and uniq"
1="Count the occurrences of different lines within a file using sort and uniq"
+++

`sort` sorts its input. `uniq` deduplicates adjacent matching lines.
Expand All @@ -20,7 +20,7 @@ Often we pipe to `sort | uniq` not just `uniq` so that duplicate lines will be n

For the following quizzes, consider the following input file:
```console
% cat input
% cat input.txt
pigs 10
chickens 2
pigs 10
Expand All @@ -31,20 +31,20 @@ hamsters 300
{{<multiple-choice
delimiter="~"
question="What command would output the lines of the file sorted alphabetically?"
answers="sort input ~ sort -u input ~ sort input | uniq"
answers="sort input.txt ~ sort -u input.txt ~ sort input.txt | uniq"
feedback="Right - sort sorts the file. ~ Not quite - what does -u do? ~ Not quite - what does piping to uniq do?"
correct="0" >}}

{{<multiple-choice
delimiter="~"
question="What command would output the lines of the file sorted by the number after the first space, starting with hamsters 300?"
answers="sort -k1 input ~ sort -k2 input ~ sort -k2 -r -n input ~ sort -k2 -n input"
answers="sort -k1 input.txt ~ sort -k2 input.txt ~ sort -k2 -r -n input.txt ~ sort -k2 -n input.txt"
feedback="Not quite - check what -k1 does. ~ Not quite - look at the difference between alphabetical sorting and numerical sorting. ~ Right! We need to select the right field, sort numerically, and reverse the order to go biggest to smallest. ~ Close, but what order will things be sorted?"
correct="2" >}}

{{<multiple-choice
delimiter="~"
question="What would the command `awk '{print $1}' input | sort | uniq -c | sort -rn` output?"
answers="The names of each animal, sorted by which has the biggest number in their line. ~ A list of each unique animal in the file, sorted by which is on the most lines. ~ A list of eaech animal, sorted alphabetically, adding together the numbers that came after them if there were duplicates."
question="What would the command `awk '{print $1}' input.txt | sort | uniq -c | sort -rn` output?"
answers="The names of each animal, sorted by which has the biggest number in their line. ~ A list of each unique animal in the file, sorted by which is on the most lines. ~ A list of each animal, sorted alphabetically, adding together the numbers that came after them if there were duplicates."
feedback="Not quite - look at the order the commands are being run in the pipeline. ~ Right! We take just the animal names, then sort them so that uniq will work, then ask uniq to count how many of each it saw, and then sort by how many uniq counted. ~ Not quite - look at the order the commands and running in the pipeline."
correct="1" >}}
8 changes: 7 additions & 1 deletion org-cyf-sdc/content/tools/sprints/2/prep/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,19 @@ weight = 1
name="Programming language concepts"
src="module/tools/programming-language-concepts"
[[blocks]]
name="Bitwise operators"
src="module/tools/bitwise-operators"
[[blocks]]
name="Comparing programming languages"
src="module/tools/comparing-programming-languages"
[[blocks]]
name = "Shell pipelines"
src="module/tools/shell-pipelines"
[[blocks]]
name="Brian Kernighan on pipelines"
src="https://www.youtube.com/watch?v=bKzonnwoR2I"
[[blocks]]
name="grep"
name="grep in pipelines"
src="module/tools/grep-in-pipelines"
[[blocks]]
name="sort and uniq"
Expand Down

0 comments on commit dc98c37

Please sign in to comment.