From 867c4e6c0ebbcf7f0aac4ce91e3efed42dc6dd6e Mon Sep 17 00:00:00 2001 From: Kristi Nakaj Date: Fri, 8 Jul 2022 15:42:03 -0400 Subject: [PATCH] fixed issue#247 --- pretext/Functions/Functionsthatreturnvalues.ptx | 2 +- pretext/Functions/Variablesandparametersarelocal.ptx | 2 +- .../GUIandEventDrivenProgramming/05_widget_grouping.ptx | 2 +- .../11_gui_program_example.ptx | 2 +- .../IntroRecursion/CalculatingtheSumofaListofNumbers.ptx | 8 ++++---- pretext/Lists/ListValues.ptx | 2 +- pretext/MoreAboutIteration/RandomlyWalkingTurtles.ptx | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/pretext/Functions/Functionsthatreturnvalues.ptx b/pretext/Functions/Functionsthatreturnvalues.ptx index 7e03b491..dc9a0507 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 198949b9..83a20885 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 a03b22b8..22171ff3 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 ea6433f5..c9d58e9b 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 7300a49f..a5ceb8a3 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 1bc82e1f..b30b2b48 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 ff6b6183..859dfd46 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