Skip to content

Commit

Permalink
merge changes with Berea fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
bnmnetp committed Jul 5, 2022
1 parent b85a1b2 commit 7d75694
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 58 deletions.
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export BOOKDIR=$(HOME)/Runestone/books/thinkcspy
export COMPDIR=$(HOME)/Runestone/RunestoneComponents
export RSURI = https://runestone.academy/cdn/runestone/

.PHONY: pretext html pdf
.PHONY: pretext html pdf runestone

help:
@echo "Unless you are converting RST to PTX you you should use this Makefile!!!!"
Expand Down Expand Up @@ -32,3 +32,8 @@ html:
pdf:
python ~/src/pretext/pretext/pretext -c all -f pdf -p $(BOOKDIR)/pretext/publication-rs-for-all.xml -x debug.rs.services.file /Users/bmiller/Runestone/RunestoneComponents/runestone/dist/webpack_static_imports.xml -d $(BOOKDIR)/pdf $(BOOKDIR)/pretext/thinkcspy.ptx

runestone:
python ~/src/pretext/pretext/pretext -c all -f html -p $(BOOKDIR)/pretext/publication-rs-academy.xml -d $(BOOKDIR)/runestone $(BOOKDIR)/pretext/thinkcspy.ptx

profile:
python -m cProfile -s cumulative ~/src/pretext/pretext/pretext -c all -f html -p $(BOOKDIR)/pretext/publication-rs-for-all.xml -d $(BOOKDIR)/beta $(BOOKDIR)/pretext/thinkcspy.ptx
26 changes: 15 additions & 11 deletions pretext/GeneralIntro/FormalandNaturalLanguages.ptx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<?xml version="1.0"?>
<section xml:id="general-intro_formal-and-natural-languages">
<title>Formal and Natural Languages</title>
<p><term>Natural languages</term> are the languages that people speak, such as English,
<p>
<term>Natural languages</term> are the languages that people speak, such as English,
Spanish, and French. They were not designed by people (although people try to
impose some order on them); they evolved naturally.</p>
<p><term>Formal languages</term> are languages that are designed by people for specific
<p>
<term>Formal languages</term> are languages that are designed by people for specific
applications. For example, the notation that mathematicians use is a formal
language that is particularly good at denoting relationships among numbers and
symbols. Chemists use a formal language to represent the chemical structure of
Expand All @@ -19,16 +21,18 @@
Tokens are the basic elements of the language, such as words, numbers, and
chemical elements. One of the problems with <c>3=+6$</c> is that <c>$</c> is not a
legal token in mathematics (at least as far as we know). Similarly,
<subscript>2</subscript>Zz is not legal because there is no element with the abbreviation
<c>Zz</c>.</p>
<subscript>2</subscript>Zz is not legal because there is no element with the abbreviation
<c>Zz</c>.
</p>
<p>The second type of syntax rule pertains to the <term>structure</term> of a statement&#x2014;
that is, the way the tokens are arranged. The statement <c>3=+6$</c> is
structurally illegal because you can't place a plus sign immediately after an
equal sign. Similarly, molecular formulas have to have subscripts after the
element name, not before.</p>
<p>When you read a sentence in English or a statement in a formal language, you
have to figure out what the structure of the sentence is (although in a natural
language you do this subconsciously). This process is called <term>parsing</term>.</p>
language you do this subconsciously). This process is called <term>parsing</term>.
</p>
<p>For example, when you hear the sentence, <q>The other shoe fell</q>, you understand
that the other shoe is the subject and fell is the verb. Once you have parsed
a sentence, you can figure out what it means, or the <term>semantics</term> of the sentence.
Expand Down Expand Up @@ -107,31 +111,31 @@
</statement>
<feedback>
Actually both languages can be parsed (determining the structure of the sentence), but formal languages can be parsed more easily in software.
</feedback>
</feedback>
</choice>
<choice correct="yes">
<statement>
<p>ambiguity, redundancy, and literalness.</p>
</statement>
<feedback>
All of these can be present in natural languages, but cannot exist in formal languages.
</feedback>
</feedback>
</choice>
<choice>
<statement>
<p>there are no differences between natural and formal languages.</p>
</statement>
<feedback>
There are several differences between the two but they are also similar.
</feedback>
</feedback>
</choice>
<choice>
<statement>
<p>tokens, structure, syntax, and semantics.</p>
</statement>
<feedback>
These are the similarities between the two.
</feedback>
</feedback>
</choice>
</choices>
</exercise>
Expand All @@ -146,15 +150,15 @@
</statement>
<feedback>
It usually takes longer to read a program because the structure is as important as the content and must be interpreted in smaller pieces for understanding.
</feedback>
</feedback>
</choice>
<choice correct="yes">
<statement>
<p>False</p>
</statement>
<feedback>
It usually takes longer to read a program because the structure is as important as the content and must be interpreted in smaller pieces for understanding.
</feedback>
</feedback>
</choice>
</choices>
</exercise>
Expand Down
89 changes: 46 additions & 43 deletions pretext/SimplePythonData/VariableNamesandKeywords.ptx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?xml version="1.0"?>
<section xml:id="simple-python-data_variable-names-and-keywords">
<title>Variable Names and Keywords</title>
<p><term>Variable names</term> can be arbitrarily long. They can contain both letters and
<p>
<term>Variable names</term> can be arbitrarily long. They can contain both letters and
digits, but they have to begin with a letter or an underscore. Although it is
legal to use uppercase letters, by convention we don't. If you do, remember
that case matters. <c>Bruce</c> and <c>bruce</c> are different variables.</p>
Expand All @@ -18,9 +19,11 @@
<pre>76trombones = "big parade"
more$ = 1000000
class = "Computer Science 101"</pre>
<p><c>76trombones</c> is illegal because it does not begin with a letter. <c>more$</c>
<p>
<c>76trombones</c> is illegal because it does not begin with a letter. <c>more$</c>
is illegal because it contains an illegal character, the dollar sign. But
what's wrong with <c>class</c>?</p>
what's wrong with <c>class</c>?
</p>
<p>It turns out that <c>class</c> is one of the Python <term>keywords</term>. Keywords define
the language's syntax rules and structure, and they cannot be used as variable
names.
Expand All @@ -31,120 +34,120 @@ class = "Computer Science 101"</pre>
<row>
<cell>
and
</cell>
</cell>
<cell>
as
</cell>
</cell>
<cell>
assert
</cell>
</cell>
<cell>
break
</cell>
</cell>
<cell>
class
</cell>
</cell>
<cell>
continue
</cell>
</cell>
</row>
<row>
<cell>
def
</cell>
</cell>
<cell>
del
</cell>
</cell>
<cell>
elif
</cell>
</cell>
<cell>
else
</cell>
</cell>
<cell>
except
</cell>
</cell>
<cell>
exec
</cell>
</cell>
</row>
<row>
<cell>
finally
</cell>
</cell>
<cell>
for
</cell>
</cell>
<cell>
from
</cell>
</cell>
<cell>
global
</cell>
</cell>
<cell>
if
</cell>
</cell>
<cell>
import
</cell>
</cell>
</row>
<row>
<cell>
in
</cell>
</cell>
<cell>
is
</cell>
</cell>
<cell>
lambda
</cell>
</cell>
<cell>
nonlocal
</cell>
</cell>
<cell>
not
</cell>
</cell>
<cell>
or
</cell>
</cell>
</row>
<row>
<cell>
pass
</cell>
</cell>
<cell>
raise
</cell>
</cell>
<cell>
return
</cell>
</cell>
<cell>
try
</cell>
</cell>
<cell>
while
</cell>
</cell>
<cell>
with
</cell>
</cell>
</row>
<row>
<cell>
yield
</cell>
</cell>
<cell>
True
</cell>
</cell>
<cell>
False
</cell>
</cell>
<cell>
None
</cell>
</cell>
<cell>
</cell>
</cell>
<cell>
</cell>
</cell>
</row>
</tabular>
</table>
Expand All @@ -155,10 +158,10 @@ class = "Computer Science 101"</pre>
remember, what the variable is used for.</p>
<warning>
<p>Beginners sometimes confuse <q>meaningful to the human readers</q> with
<q>meaningful to the computer</q>. So they'll wrongly think that because
<q>meaningful to the computer</q>. So they'll wrongly think that because
they've called some variable <c>average</c> or <c>pi</c>, it will somehow
automagically calculate an average, or automagically associate the variable
<c>pi</c> with the value 3.14159. No! The computer doesn't attach semantic
<c>pi</c> with the value 3.14159. No! The computer doesn't attach semantic
meaning to your variable names.</p>
<p>So you'll find some instructors who deliberately don't choose meaningful
names when they teach beginners &#x2014; not because they don't think it is a
Expand All @@ -181,15 +184,15 @@ class = "Computer Science 101"</pre>
</statement>
<feedback>
- The + character is not allowed in variable names.
</feedback>
</feedback>
</choice>
<choice correct="yes">
<statement>
<p>False</p>
</statement>
<feedback>
- The + character is not allowed in variable names (everything else in this name is fine).
</feedback>
</feedback>
</choice>
</choices>
</exercise>
Expand Down
2 changes: 1 addition & 1 deletion pretext/bookinfo.ptx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.

<!-- Prefix to enhance Sage notebook contents -->
<initialism>SB</initialism>

<blurb shelf="introcs">The original open source intro to computer science textbook. Great for students of all ages.</blurb>
<!-- Math-related macros from "macros.tex" in previous LaTeX version -->
<!-- \notdivide replaces \notmid to avoid conflict with tikz - TWJ 5/6/2010 -->
<!-- Added operator \gf - TWJ 2/26/2013 -->
Expand Down
3 changes: 1 addition & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
runestone>=4.0.0
psycopg2-binary
pretextbook >= 0.8.0

0 comments on commit 7d75694

Please sign in to comment.