Skip to content

Commit e96fc0c

Browse files
committed
Add <introduction> sections.
1 parent 31bd793 commit e96fc0c

25 files changed

Lines changed: 58 additions & 12 deletions

pretext/Debugging/BeginningtipsforDebugging.ptx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<title>Beginning tips for Debugging</title>
44
<p>Debugging a program is a different way of thinking than writing a program. The process of debugging is much more like being a detective. Here are a few rules to get you thinking about debugging.</p>
55
<p>
6-
<ol label="1">
6+
<ol marker="1">
77
<li>
88
<p>Everyone is a suspect (Except Python)! It's common for beginner programmers to blame Python, but that should be your last resort. Remember that Python has been used to solve CS1 level problems millions of times by millions of other programmers. So, Python is probably not the problem.</p>
99
</li>

pretext/Debugging/KnowyourerrorMessages.ptx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?xml version="1.0"?>
22
<section xml:id="debugging_know-your-error-messages">
33
<title>Know Your Error Messages</title>
4+
<introduction>
45
<p>Many problems in your program will lead to an error message. For example as I was writing and testing this chapter of the book I wrote the following version of the example program in the previous section.</p>
56
<program language="python">
67
<input>
@@ -227,10 +228,11 @@ print(final_time_int)
227228
</li>
228229
</ul>
229230
</p>
231+
</introduction>
230232
<subsection xml:id="debugging_parseerror">
231233
<title>ParseError</title>
232234
<p>Parse errors happen when you make an error in the syntax of your program. Syntax errors are like making grammatical errors in writing. If you don't use periods and commas in your writing then you are making it hard for other readers to figure out what you are trying to say. Similarly Python has certain grammatical rules that must be followed or else Python can't figure out what you are trying to say.</p>
233-
<p>Usually ParseErrors can be traced back to missing punctuation characters, such as parentheses, quotation marks, or commas. Remember that in Python commas are used to separate parameters to functions. Paretheses must be balanced, or else Python thinks that you are trying to include everything that follows as a parameter to some function.</p>
235+
<p>Usually ParseErrors can be traced back to missing punctuation characters, such as parentheses, quotation marks, or commas. Remember that in Python commas are used to separate parameters to functions. Parentheses must be balanced, or else Python thinks that you are trying to include everything that follows as a parameter to some function.</p>
234236
<p>Here are a couple examples of Parse errors in the example program we have been using. See if you can figure out what caused them.</p>
235237
<exercise>
236238
<statement/>

pretext/Exceptions/05_exceptions_syntax.ptx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
<?xml version="1.0"?>
22
<section xml:id="exceptions_exceptions-syntax">
33
<title>Exceptions Syntax</title>
4+
<introduction>
45
<p>There are many variations on the code that catches exceptions. Here is a
56
brief summary, but other code variations are possible.</p>
7+
</introduction>
68
<subsection xml:id="exceptions_catch-all-exceptions">
79
<title>Catch All Exceptions</title>
810
<p>Catch all exceptions, regardless of their type. This will prevent

pretext/Functions/Exercises.ptx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ drawPoly(tess, 8, 50)
122122
<exercise label="ex_5_5">
123123
<statement>
124124
<p>The two spirals in this picture differ only by the turn angle. Draw both.</p>
125-
<image source="Functions/Figures/tess_spirals.png" width="50%" height="240"/>
125+
<image source="Functions/Figures/tess_spirals.png" width="50%"/>
126126
</statement>
127127
<program interactive="activecode" language="python" xml:id="ex_5_5_editor">
128128
<input>

pretext/Functions/TheAccumulatorPattern.ptx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?xml version="1.0"?>
22
<section xml:id="functions_the-accumulator-pattern">
33
<title>The Accumulator Pattern</title>
4+
<introduction>
45
<video xml:id="function_accumulator_pattern" youtube="aqhREpceEMI" width="auto"/>
56
<p>In the previous example, we wrote a function that computes the square of a number. The algorithm we used
67
in the function was simple: multiply the number by itself.
@@ -60,6 +61,7 @@ squareResult = square(toSquare)
6061
print("The result of", toSquare, "squared is", squareResult)
6162
</input>
6263
</program>
64+
</introduction>
6365
<subsection xml:id="functions_the-general-accumulator-pattern">
6466
<title>The General Accumulator Pattern</title>
6567
<program language="python">

pretext/Functions/UnitTesting.ptx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?xml version="1.0"?>
22
<section xml:id="functions_unit-testing">
33
<title>Unit Testing</title>
4+
<introduction>
45
<p>A <term>test case</term> expresses requirements for a program, in a way that can be checked automatically. Specifically, a test
56
asserts something about the state of the program at a particular point in its execution. A <term>unit test</term> is an automatic
67
procedure used to validate that individual units of code are working properly. A function is one form of a unit.
@@ -99,6 +100,7 @@ assert type(9.0//5) == int
99100
</choice>
100101
</choices>
101102
</exercise>
103+
</introduction>
102104
<subsection xml:id="functions_assert-with-for-loops">
103105
<title><c>assert</c> with <c>for</c> loops</title>
104106
<p>Why would you ever want to write a line of code that can never compute anything useful for you, but sometimes causes

pretext/GUIandEventDrivenProgramming/02_standard_dialog_boxes.ptx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
<?xml version="1.0"?>
22
<section xml:id="gu-iand-event-driven-programming_tkinter-standard-dialog-boxes">
33
<title>Tkinter Standard Dialog Boxes</title>
4+
<introduction>
45
<p>There are many common programming tasks that can be performed using
56
pre-defined GUI dialog boxes. The following discussion describes these
67
dialog boxes and provides some simple examples. You can refer to the
78
Python documentation for additional optional parameters.</p>
9+
</introduction>
810
<subsection xml:id="gu-iand-event-driven-programming_messages">
911
<title>Messages</title>
1012
<p>A <c>messagebox</c> can display information to a user.

pretext/GUIandEventDrivenProgramming/10_timer_events.ptx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?xml version="1.0"?>
22
<section xml:id="gu-iand-event-driven-programming_timer-events">
33
<title>Timer Events</title>
4+
<introduction>
45
<p>GUI programs run an <q>event loop</q> that continuously receive events from the
56
operating system and <q>dispatches</q> those events to appropriate callback
67
functions. Nothing happens in a GUI program without an event. The application
@@ -22,6 +23,7 @@ my_button = tk.Button(application_window, text="Example")
2223
my_button.after(1000, a_callback_function)
2324
</input>
2425
</program>
26+
</introduction>
2527
<subsection xml:id="gu-iand-event-driven-programming_animations-and-repeated-tasks">
2628
<title>Animations and Repeated Tasks</title>
2729
<p>If you want a specific task to be repeated on a regular interval, then

pretext/GUIandEventDrivenProgramming/11_gui_program_example.ptx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?xml version="1.0"?>
22
<section xml:id="gu-iand-event-driven-programming_a-programming-example">
33
<title>A Programming Example</title>
4+
<introduction>
45
<p>Let's develop a non-trivial GUI program to demonstrate the material presented
56
in the previous lessons. We will develop a GUI Whack-a-mole
67
game where a user tries to click on <q>moles</q> as they randomly pop up out of
@@ -38,6 +39,7 @@
3839
always be executable. You continually add a few lines of code and then test
3940
them. If errors occur you almost always know were the errors came from!
4041
They came from the lines of code you just added.</p>
42+
</introduction>
4143
<subsection xml:id="gu-iand-event-driven-programming_a-whack-a-mole-game">
4244
<title>A Whack-a-mole Game</title>
4345
<p>Step 1: Make sure you have a reasonable GUI design and implementation plan

pretext/GUIandEventDrivenProgramming/12_model_view_controller.ptx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?xml version="1.0"?>
22
<section xml:id="gu-iand-event-driven-programming_managing-gui-program-complexity">
33
<title>Managing GUI Program Complexity</title>
4+
<introduction>
45
<p>As we explained in a previous lesson, GUI programs are best implemented as
56
Python classes because it allows you to manage the scope of the variables
67
in your GUI interface and callback functions. However, as GUI programs
@@ -55,6 +56,7 @@ controller (input) --&gt; model (processing) --&gt; view (output)
5556
the same stages of development we used in the previous lesson are a good
5657
approach, but we will create a separate Python <c>class</c> for most of the
5758
stages. Let's walk through the code development.</p>
59+
</introduction>
5860
<subsection xml:id="gu-iand-event-driven-programming_creating-the-view">
5961
<title>Creating the <em>View</em></title>
6062
<p>Let's create a Python <c>class</c> that builds the user interface for a

0 commit comments

Comments
 (0)