Skip to content

Commit

Permalink
many small workbook fixes (see #2395)
Browse files Browse the repository at this point in the history
  • Loading branch information
flannery-denny committed Feb 12, 2025
1 parent 0c34a59 commit e8c8b3f
Show file tree
Hide file tree
Showing 13 changed files with 73 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
++++
== Complete the Code by Filling in the Blanks!

Finish the Code by filling in the blanks. +
@teacher{The answers below are shown with _all_ parentheses included. There are also correct solutions in which the unnecessary parentheses are left out.}
Finish the Code by filling in the blanks.

@do{
(define expra '(overlay (circle 5 "solid" "tan") (square 9 "solid" "red")))
Expand All @@ -22,8 +21,7 @@ Finish the Code by filling in the blanks. +
== Complete the Code by adding Parentheses
For each Circle of Evaluation, finish the Code by adding parentheses@ifproglang{pyret}{ and commas}. +
@teacher{The answers below are shown with _all_ parentheses included. There are also correct solutions in which the unnecessary parentheses are left out.}
For each Circle of Evaluation, finish the Code by adding parentheses@ifproglang{pyret}{ and commas}.
@do{
(define expr1 '(beside (triangle 5 "solid" "blue") (circle 8 "outline" "red")))
Expand All @@ -35,8 +33,10 @@ For each Circle of Evaluation, finish the Code by adding parentheses@ifproglang{
@vspace{1ex}
@ifnotsoln{
[.codetwo]
beside @hspace{1em} triangle @hspace{1em} 5 @hspace{1em} "solid" @hspace{1em} "blue" @hspace{1em} circle @hspace{1em} 8 @hspace{1em} "outline" "red"
}
@showsoln{(code expr1 #:parens true)}
Expand All @@ -46,8 +46,10 @@ beside @hspace{1em} triangle @hspace{1em} 5 @hspace{1em} "solid" @hspace{1em} "b
@vspace{1ex}
@ifnotsoln{
[.codetwo]
rotate @hspace{1em} 8 @hspace{1em} above @hspace{1em} star @hspace{1em} 5 @hspace{1em} "solid" @hspace{1em} "gold" @hspace{1em} triangle @hspace{1em} 3 @hspace{1em} "solid" @hspace{1em} "green"
}
@showsoln{(code expr2 #:parens true)}
Expand All @@ -57,8 +59,10 @@ rotate @hspace{1em} 8 @hspace{1em} above @hspace{1em} star @hspace{1em} 5 @hspac
@vspace{1ex}
@ifnotsoln{
[.codetwo]
beside @hspace{1em} rotate @hspace{1em} 9 @hspace{1em} triangle @hspace{1em} 5 @hspace{1em} "solid" @hspace{1em} "blue" @hspace{1em} circle @hspace{1em} 8 @hspace{1em} "outline" @hspace{1em} "red"
}
@showsoln{(code expr3 #:parens true)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Programming languages involve different @vocab{data types}, such as Numbers, Str

** Numbers are _usually_ used for quantitative data and other values are _usually_ used as categorical data.

@ifproglang{pyret}{** In Pyret, any decimal _must_ start with a 0. For example, `0.22` is valid, but `.22` is not.}
@ifproglang{pyret}{** In Pyret, decimals _must_ start with a zero. For example, `0.22` is valid, but `.22` is not.}

- Strings are values like `"Emma"`, `"Rosanna"`, `"Jen and Ed"`, or even `"08/28/1980"`.

Expand Down Expand Up @@ -48,7 +48,7 @@ Applying functions @ifproglang{wescheme}{(and operators!)} works much the way it
- Applying the operator @math{+} to the inputs 1 and 2 would look like @show{(code '(+ 1 2))}.
}
- Applying a function to make images would look like @show{(code '(star 50 "solid" "red"))}.
- There are many other functions, for example @show{(code 'sqr)}, @show{(code 'sqrt)}, @show{(code 'triangle)}, @show{(code 'square)}, @show{(code 'string-repeat)}, etc.
- There are many other functions in @proglang, for example @show{(code 'sqr)}, @show{(code 'sqrt)}, @show{(code 'triangle)}, @show{(code 'square)}, @show{(code 'string-repeat)}, etc.

@vspace{1ex}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@

@fitb{}{@showsoln{(contract 'triangle '(Number String String) "Image")}}

@vspace{1ex}
@n Read the explanation below. Then explain the difference in your own words.

@indented{
*syntax errors* - when the computer cannot make sense of the code because of unclosed strings, missing commas or parentheses, etc.
*contract errors* - when the function isn't given what it needs (the wrong type or number of arguments are used)
}

@n The difference between *syntax errors* and *contract errors* is: @fitb{}{}
 The difference between *syntax errors* and *contract errors* is: @fitb{}{}

@fitb{}{}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@
++++
<style>
table .autonum::after { content: ')' !important; }
/* Push content to the top (instead of the default vertical distribution), which was leaving empty space at the top. */
#content { display: block !important; }
</style>
++++

[.no-flex-section]
== Notice and Wonder

@do{
Expand Down Expand Up @@ -45,12 +43,14 @@ _Suppose we want to see the `text` "Diego" written vertically in yellow letters
_Suppose you wanted the computer to show your name in your favorite color and rotate it so that it's diagonal..._
[.FillVerticalSpace, cols=".<1a, .<1a", stripes="none"]
[.FillVerticalSpace, cols=".<1a, .<1a", stripes="none", grid="none", frame="none"]
|===
| @n Draw the circle of evaluation to generate the image of your name in your favorite color.
| @n Draw the circle of evaluation to: +
 generate the image of your name in your favorite color
| @n Draw the circle of evaluation to `rotate` it so that it's diagonal.
| @n Draw the circle of evaluation to: +
 `rotate` the image so that it's diagonal
^| @showsoln{(coe '(text "Shriram" 45 "purple"))} ^| @showsoln{(coe exp2)}
@ifnotsoln{@vspace{35ex}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,64 +7,67 @@ table .autonum::after { content: ')' !important; }
</style>
++++

Use the contracts to write expressions to generate images similar to those pictured. Go to @starter-file{editor} to test your code.
@link-instructions{
For questions 1,2,4,5,8 & 9, use the contracts provided to find expressions that will generate images similar to the ones pictured. +
Test your code in @starter-file{editor} before recording it.
}

@teacher{The numbers used in student code will vary, but should have relationships proportional to the ones shown in the solutions.}

@center{@show{(contract 'ellipse '((width Number) (height Number) (fill-style String) (color String)) "Image")}}
[.FillVerticalSpace, cols="^.^1a,^.^2a",stripes="none"]
[.FillVerticalSpace, cols="1a, 7a,^.^14a",stripes="none"]
|===
| @n
| @centered-image{../images/ellipse-50-150-outline.png, 30}
| @n Use the Contract to write an expression that generates a similar image:
@showsoln{(code '(ellipse 50 150 "outline" "black")) }
| @showsoln{(code '(ellipse 50 150 "outline" "black")) }
| @n
| @centered-image{../images/ellipse-150-50-solid.png, 60}
| @n Use the Contract to write an expression that generates a similar image:
| @showsoln{(code '(ellipse 150 50 "solid" "black")) }
@showsoln{(code '(ellipse 150 50 "solid" "black")) }
| @n Write an expression using @show{(code 'ellipse)} to produce a circle.
| @n
| Write an expression using @show{(code 'ellipse)} to produce a circle.
| @showsoln{(code '(ellipse 50 50 "solid" "black")) }
|===
@center{@show{(contract 'regular-polygon '((side-length Number) (number-of-sides Number) (fill-style String) (color String)) "Image")}}
[.FillVerticalSpace, cols="^.^1a,^.^2a",stripes="none"]
[.FillVerticalSpace, cols="1a, 7a,^.^14a",stripes="none"]
|===
| @n
| @centered-image{../images/reg-polygon-50-5-solid.png, 50}
| @nUse the Contract to write an expression that generates a similar image:
@showsoln{(code '(regular-polygon 50 5 "solid" "black")) }
| @showsoln{(code '(regular-polygon 50 5 "solid" "black")) }
| @n
| @centered-image{../images/reg-polygon-25-8-outline.png, 50}
| @nUse the Contract to write an expression that generates a similar image:
| @showsoln{(code '(regular-polygon 25 8 "outline" "black")) }
@showsoln{(code '(regular-polygon 25 8 "outline" "black")) }
| @n Use @show{(code 'regular-polygon)} to write an expression for a square!
| @n
| Use @show{(code 'regular-polygon)} to write an expression for a square!
| @showsoln{(code '(regular-polygon 50 4 "solid" "black")) }
| @n How would you describe a *regular polygon* to a friend?
| @n
| How would you describe a *regular polygon* to a friend?
| @ifsoln{a closed shape made of equal-length straight lines, all joined at the same angle}
|===
@center{@show{(contract 'rhombus '((size Number) (top-angle Number) (fill-style String) (color String)) "Image")}}
[.FillVerticalSpace, cols="^.^1,^.^2",stripes="none"]
[.FillVerticalSpace, cols="1a, 7a,^.^14a",stripes="none"]
|===
| @n
| @centered-image{../images/rhombus-100-140-solid.png, 60}
| @n Use the Contract to write an expression that generates a similar image:
@showsoln{(code '(rhombus 100 140 "solid" "black")) }
| @showsoln{(code '(rhombus 100 140 "solid" "black")) }
| @n
| @centered-image{../images/rhombus-100-40-outline.png, 30}
| @n Use the Contract to write an expression that generates a similar image:
@showsoln{(code '(rhombus 100 40 "outline" "black")) }
| @showsoln{(code '(rhombus 100 40 "outline" "black")) }
| @n Write an expression to generate a @show{(code 'rhombus)} that is a square!
| @n
| Write an expression to generate a @show{(code 'rhombus)} that is a square!
| @showsoln{(code '(rhombus 100 90 "solid" "black")) }
|===
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Programming languages involve different @vocab{data types}, such as Numbers, Str

** Numbers are _usually_ used for quantitative data and other values are _usually_ used as categorical data.

@ifproglang{pyret}{** In Pyret, any decimal _must_ start with a 0. For example, `0.22` is valid, but `.22` is not.}
@ifproglang{pyret}{** In Pyret, decimals _must_ start with a zero. For example, `0.22` is valid, but `.22` is not.}

- Strings are values like `"Emma"`, `"Rosanna"`, `"Jen and Ed"`, or even `"08/28/1980"`.

Expand Down Expand Up @@ -40,7 +40,7 @@ Operators (like `+`, `-`, `*`, `<`, etc.) work the same way in Pyret that they d

== Applying Functions

Applying functions @ifproglang{wescheme}{(and operators!)} works much the way it does in math. Every function has a name, takes some inputs, and produces some output. The function name is written first, followed by a list of @vocab{arguments} @ifproglang{pyret}{in parentheses}.
Functions @ifproglang{wescheme}{(and operators!)} work much the way they do in math. Every function has a name, takes some inputs, and produces some output. The function name is written first, followed by a list of @vocab{arguments} @ifproglang{pyret}{in parentheses}.

- In math this could look like @math{f(5)} or @math{g(10, 4)}.
- In @proglang, these examples would be written as @show{(code '(f 5))} and @show{(code '(g 10 4))}.
Expand All @@ -50,7 +50,7 @@ Applying functions @ifproglang{wescheme}{(and operators!)} works much the way it
- Applying a function to make images would look like @show{(code '(star 50 "solid" "red"))}.
// Need to use wescheme function names to get proper rendering in wescheme and pyret workbooks
// Need to update lib/langtable when ready to switch to pyret aliases.
- There are many other functions, for example @show{(code 'sqr)}, @show{(code 'sqrt)}, @show{(code 'triangle)}, @show{(code 'square)}, @show{(code 'string-repeat)}, etc.
- There are many other functions in @proglang, for example @show{(code 'sqr)}, @show{(code 'sqrt)}, @show{(code 'triangle)}, @show{(code 'square)}, @show{(code 'string-repeat)}, etc.

@vspace{1ex}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Try typing in `4 + 2` and then `4+2` (without the spaces). What can you concl

@fitb{}{@ifsoln{Operators require spaces.}}

@n Type in the following expressions, *one at a time*: `4 + 2 * 6` `(4 + 2) * 6` `4 + (2 * 6)` What do you notice?
@n Type in the following expressions, *one at a time*: `4 + 2 * 6` @hspace{1em} `(4 + 2) * 6`@hspace{1em} `4 + (2 * 6)` @hspace{1em} What do you notice?

@fitb{}{@ifsoln{If you use more than one operator you have to insert parentheses to tell the computer which operation to apply first.}}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Now test out the expression @show{(code '(pie-chart more-animals "species"))}
Note: When you first build a bar chart or pie chart in Pyret, they are interactive visualizations. That means that you can mouse over them for more information. Hit the up arrow in the interactions area to reload your last expression and test it out!

== Part 2 - Comparing Bar and Pie Charts
_Best completed after @printable-exercise{bar-and-pie-notice.adoc} and @printable-exercise{matching-bar-to-pie.adoc}_
_Best completed after @printable-exercise{bar-and-pie-notice.adoc} and @printable-exercise{matching-bar-to-pie.adoc}._

@n How are pie charts similar to bar charts?

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ Fortunately, Pyret has two functions that let us specify both a group and a subg

@n Which display would be most efficient for answering the question: "What percentage of cats are female?" Why?

@fitb{}{@ifsoln{stacked bar chart}}
@fitb{}{@ifsoln{stacked bar chart because there's a bar for each species showing the % breakdown of the species by sex}}

@n Which display would be most efficient for answering the question: "Are there more cats or dogs?" Why?

@fitb{}{@ifsoln{multi bar chart}}
@fitb{}{@ifsoln{multi bar chart because we see bars representing the count of each species by sex.}}

@n Write a question of your own that involves comparing subgroups across groups. @fitb{}{}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ Complete the sentences below by *circling* the behavior you observed for each Bo
[cols="2a, ^3a, ^3a", frame="none", grid="none", stripes="none"]
|===
|(a) `true` sorts the table...
| in *ascending order* _(least to greatest)_
| in *ascending order* _(from least to greatest)_
| in *descending order* _(from largest to smallest)_

|(b) `false` sorts the table...
| in *ascending order* _(from least to greatest)_
| in *descending order* _(from largest to smallest)_
|===

@n The Domain of `sort` has three inputs. One of them is the table itself. Can you identify the dataypes of the other two?
@n The Domain of `sort` has three inputs. One of them is the table itself. Can you identify the datatypes of the other two?

@indented{
@ifnotsoln{@show{(contract 'sort '((table-name Table) (column-name " ") (order " ")) "Table")}}
Expand All @@ -51,19 +51,19 @@ Let's explore another table function, beginning with its contract:

@show{(contract "count" '("Table" "String") "Table")}

@n What do you expect the code @show{(code '(count animals-table "legs"))} to produce?
@n What do you expect the code @show{(code '(count animals-table "legs"))} to produce? @fitb{}{}

@fitb{}{@ifsoln{answers will vary, but students should be able to predict that they will get a new table!}}

Type the code into the Interactions Area and click "Enter" to test it out.
 Type the code into the Interactions Area and click "Enter" to test it out.

@n How many animals had 4 legs? @fitb{}{@ifsoln{29}}

@n Think of another question you might be able to answer by making a different table using the `count` function.

@fitb{}{@ifsoln{Possible response: How many animals are cats?}}

Fill in the blanks with the code you'd write: @fitbruby{8em}{@ifsoln{count}}{function-name} (@fitbruby{18em}{@ifsoln{animals-table}}{table-name {two-colons} Table}, @fitbruby{14em}{@ifsoln{Answers will vary!}}{column-name {two-colons} String})
@n Fill in the blanks with the code to make the table: @fitbruby{8em}{@ifsoln{count}}{function-name} (@fitbruby{15em}{@ifsoln{animals-table}}{table-name {two-colons} Table}, @fitbruby{13em}{@ifsoln{Answers will vary!}}{column-name {two-colons} String})

@n Try using the `count` function to summarize the `pounds` column. Is the resulting summary useful? Why or why not? @fitb{}{} +
@fitb{}{@ifsoln{No - nearly every animal has a unique weight, so the resulting table is almost as long as the original!}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,14 @@
@fitb{}{@ifsoln{The Domain of the sort function is Table, String, Boolean.}}
== What Kind of Error is it?
@n Read the explanations below. Then explain the difference in your own words.
[.indentedpara]
--
@vocab{syntax errors} - when the computer cannot make sense of the code because of unclosed strings, missing commas or parentheses, etc.
@vocab{contract errors} - when the function isn't given what it needs (the wrong type or number of arguments are used)
--
@indented{
*syntax errors* - when the computer cannot make sense of the code because of unclosed strings, missing commas or parentheses, etc.
*contract errors* - when the function isn't given what it needs (the wrong type or number of arguments are used)
}
@n In your own words, the difference between @vocab{syntax errors} and @vocab{contract errors} is: @fitb{}{}
 The difference between @vocab{syntax errors} and @vocab{contract errors} is: @fitb{}{}
@fitb{}{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ A *dot plot* (below) is a data visualization consisting of data points plotted a

@center{@image{../images/get-ready-min.png, 300}}

On the dot plot (above), each data point represents one student in a sample. The position of the data point indicates how many minutes it takes for that student to get ready for school.
On the dot plot (above), each data point represents one student in a sample.

The position of the data point indicates how many minutes it takes for that student to get ready for school. We see, for example, that there is only one students who gets ready in 10 minutes and there are 8 students who take 15 minutes to get ready.

@vspace{1ex}

Expand All @@ -14,7 +16,7 @@ On the dot plot (above), each data point represents one student in a sample. The
- A *cluster* is a group of data points that are close together. _Most of the data in the dot plot above is clustered from 10-60, meaning that most students spend between 10 minutes and an hour getting ready for school in the morning._
- A *gap* is an interval where there are no data points. _On the dot plot above, there is a gap from 60 to 90. In this sample, no one takes between 60 and 90 minutes to get ready._
- An *outlier* occurs when one data point is much larger or smaller than the other data points. _There is an outlier on the above dot plot at 90. One student requires much more time to get ready in the morning._
- A *peak* is the value(s) with the most data. _On the dot plot, 45 minutes is the most common amount of time spent getting ready for school._
- A *peak* is the value(s) with the most data. _In this sample, 45 minutes is the most common amount of time spent getting ready for school._
@vspace{1ex}

Expand All @@ -32,6 +34,6 @@ On the dot plot (above), each data point represents one student in a sample. The
- *Statistical questions* are questions that anticipate variability.
- "How many inches are in a foot?" does not anticipate variability. The answer is always 12.
- "In general, how tall are the students in your class?" does anticipate variability.
- "How many inches are in a foot?" does not anticipate variability. The answer is always 12.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
notes.adoc
our-class-name-data.adoc
notes-dot-plots-distribution-typicality-variability.adoc
interpret-dot-plots.adoc
our-class-name-data.adoc
variability-two-ways.adoc
variability-of-dot-plots.adoc
animal-weight-variability.adoc

0 comments on commit e8c8b3f

Please sign in to comment.