diff --git a/pretext/Functions/Functionsthatreturnvalues.ptx b/pretext/Functions/Functionsthatreturnvalues.ptx index 7e03b491a..dc9a0507f 100644 --- a/pretext/Functions/Functionsthatreturnvalues.ptx +++ b/pretext/Functions/Functionsthatreturnvalues.ptx @@ -43,7 +43,7 @@ print(max(3 * 11, 5 ** 3, 512 - 9, 1024 ** 0)) 125, and 1. Note that max also works on lists of values.

Furthermore, functions like range, int, abs all return values that can be used to build more complex expressions.

-

So an important difference between these functions and one like drawSquare is that +

So an important difference between these functions and one like drawSquare is that drawSquare was not executed because we wanted it to compute a value — on the contrary, we wrote drawSquare because we wanted it to execute a sequence of steps that caused the turtle to draw a specific shape.

diff --git a/pretext/Functions/Variablesandparametersarelocal.ptx b/pretext/Functions/Variablesandparametersarelocal.ptx index 198949b90..83a208853 100644 --- a/pretext/Functions/Variablesandparametersarelocal.ptx +++ b/pretext/Functions/Variablesandparametersarelocal.ptx @@ -40,7 +40,7 @@ result = badsquare(10) print(result) -

Although the badsquare function works, it is silly and poorly written. We have done it here to illustrate +

Although the badsquare function works, it is silly and poorly written. We have done it here to illustrate an important rule about how variables are looked up in Python. First, Python looks at the variables that are defined as local variables in the function. We call this the local scope. If the variable name is not diff --git a/pretext/GUIandEventDrivenProgramming/05_widget_grouping.ptx b/pretext/GUIandEventDrivenProgramming/05_widget_grouping.ptx index a03b22b85..22171ff34 100644 --- a/pretext/GUIandEventDrivenProgramming/05_widget_grouping.ptx +++ b/pretext/GUIandEventDrivenProgramming/05_widget_grouping.ptx @@ -56,7 +56,7 @@ and location using a layout manager. The image below shows examples of the four types of widget containers. The containers in this example used a grid layout manager on a 2x2 grid.

-
+
Examples of grouping widgets
diff --git a/pretext/GUIandEventDrivenProgramming/11_gui_program_example.ptx b/pretext/GUIandEventDrivenProgramming/11_gui_program_example.ptx index ea6433f56..c9d58e9b4 100644 --- a/pretext/GUIandEventDrivenProgramming/11_gui_program_example.ptx +++ b/pretext/GUIandEventDrivenProgramming/11_gui_program_example.ptx @@ -43,7 +43,7 @@

Step 1: Make sure you have a reasonable GUI design and implementation plan before you start coding. Draw a sketch of your initial design on paper and consider how a user will interact with your program.

-
+
Initial design of a Whack-a-mole game
diff --git a/pretext/IntroRecursion/CalculatingtheSumofaListofNumbers.ptx b/pretext/IntroRecursion/CalculatingtheSumofaListofNumbers.ptx index 7300a49fe..a5ceb8a32 100644 --- a/pretext/IntroRecursion/CalculatingtheSumofaListofNumbers.ptx +++ b/pretext/IntroRecursion/CalculatingtheSumofaListofNumbers.ptx @@ -26,17 +26,17 @@ print(listsum([1,3,5,7,9])) problem from adding a list to adding pairs of numbers, we could rewrite the list as a fully parenthesized expression. Such an expression looks like this:

- ((((1 + 3) + 5) + 7) + 9) + ((((1 + 3) + 5) + 7) + 9)

We can also parenthesize the expression the other way around,

- (1 + (3 + (5 + (7 + 9)))) + (1 + (3 + (5 + (7 + 9))))

Notice that the innermost set of parentheses, (7 + 9), is a problem that we can solve without a loop or any special constructs. In fact, we can use the following sequence of simplifications to compute a final sum.

- total = \ (1 + (3 + (5 + (7 + 9)))) \\ + total = \ (1 + (3 + (5 + (7 + 9)))) \\ total = \ (1 + (3 + (5 + 16))) \\ total = \ (1 + (3 + 21)) \\ total = \ (1 + 24) \\ @@ -46,7 +46,7 @@ total = \ 25 the sum of the list numList is the sum of the first element of the list (numList[0]), and the sum of the numbers in the rest of the list (numList[1:]). To state it in a functional form:

- listSum(numList) = first(numList) + listSum(rest(numList)) + listSum(numList) = first(numList) + listSum(rest(numList)) \label{eqn:listsum}

In this equation first(numList) returns the first element of the list and rest(numList) returns a list of everything but diff --git a/pretext/Lists/ListValues.ptx b/pretext/Lists/ListValues.ptx index 1bc82e1f8..b30b2b489 100644 --- a/pretext/Lists/ListValues.ptx +++ b/pretext/Lists/ListValues.ptx @@ -35,7 +35,7 @@ newlist = [ numbers, vocabulary ] print(newlist) -

+

Check your understanding

diff --git a/pretext/MoreAboutIteration/RandomlyWalkingTurtles.ptx b/pretext/MoreAboutIteration/RandomlyWalkingTurtles.ptx index ff6b61832..859dfd466 100644 --- a/pretext/MoreAboutIteration/RandomlyWalkingTurtles.ptx +++ b/pretext/MoreAboutIteration/RandomlyWalkingTurtles.ptx @@ -172,7 +172,7 @@ wn.exitonclick() that if you ever need to write a similar program, you can reuse this function with confidence the next time you need it. Breaking up this program into a couple of parts is another example of functional decomposition.

-

+

Check your understanding