You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: pretext/ClassesDiggingDeeper/Fractions.ptx
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@
9
9
on the top is called the numerator and the number on the bottom is called the denominator. Sometimes people use a slash
10
10
for the line and sometimes they use a straight line. The fact is that it really does not matter so long as you know which
11
11
is the numerator and which is the denominator.</p>
12
-
<p>To design our class, we simply need to use the analysis above to realize that the <title_reference>state</title_reference> of a fraction object can be
12
+
<p>To design our class, we simply need to use the analysis above to realize that the state of a fraction object can be
13
13
completely described by representing two integers. We can begin by implementing the <c>Fraction</c> class and the <c>__init__</c>
14
14
method which will allow the user to provide a numerator and a denominator for the fraction being created.</p>
<p>Write a program called <c>alice_words.py</c> that creates a text file named
140
140
<c>alice_words.txt</c> containing an alphabetical listing of all the words, and the
141
-
number of times each occurs, in the text version of <title_reference>Alice's Adventures in Wonderland</title_reference>.
141
+
number of times each occurs, in the text version of Alice's Adventures in Wonderland.
142
142
(You can obtain a free plain text version of the book, along with many others, from
143
143
<urlhref="http://www.gutenberg.org"visual="http://www.gutenberg.org">http://www.gutenberg.org</url>.) The first 10 lines of your output file should look
144
144
something like this</p>
@@ -263,7 +263,7 @@ for word in keys:
263
263
out.write('\n')
264
264
265
265
print("The word 'alice' appears " + str(count['alice']) + " times in the book.")
Copy file name to clipboardExpand all lines: pretext/Files/AlternativeFileReadingMethods.ptx
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -145,6 +145,6 @@ infile.close()
145
145
blank line in the file actually has a single character, the <c>\n</c> character (newline).
146
146
So, the only way that a line of data from the
147
147
file can be empty is if you are reading at the end of the file, and the <c>while</c> condition becomes <c>False</c>.</p>
148
-
<p>Finally, notice that the last line of the body of the <c>while</c> loop performs another <c>readline</c>. This statement will reassign the variable <c>line</c> to the next line of the file. It represents the <title_reference>change of state</title_reference> that is necessary for the iteration to
148
+
<p>Finally, notice that the last line of the body of the <c>while</c> loop performs another <c>readline</c>. This statement will reassign the variable <c>line</c> to the next line of the file. It represents the change of state that is necessary for the iteration to
149
149
function correctly. Without it, there would be an infinite loop processing the same line of data over and over.</p>
Copy file name to clipboardExpand all lines: pretext/Files/WithStatements.ptx
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -22,5 +22,5 @@ with open('mydata.txt') as md:
22
22
print(md)
23
23
</input>
24
24
</program>
25
-
<p>The first line of the <title_reference>with</title_reference> statement opens the file and assigns it to <title_reference>md</title_reference> then we can iterate over the file in any of the usual ways. and when we are done we simply stop indenting and let Python take care of closing the file and cleaning up.</p>
25
+
<p>The first line of the with statement opens the file and assigns it to md then we can iterate over the file in any of the usual ways. and when we are done we simply stop indenting and let Python take care of closing the file and cleaning up.</p>
@@ -228,7 +228,7 @@ print("The sum from 1 to 5 is",t)
228
228
</exercise>
229
229
<exerciselabel="ex_5_8">
230
230
<statement>
231
-
<p>Write a function <title_reference>areaOfCircle(r)</title_reference> which returns the area of a circle of radius <title_reference>r</title_reference>. Make sure you use the math module in your solution.</p>
231
+
<p>Write a function areaOfCircle(r) which returns the area of a circle of radius r. Make sure you use the math module in your solution.</p>
<p>Write a function called <title_reference>myPi</title_reference> that will return an approximation of PI (3.14159…). Use the <urlhref="http://en.wikipedia.org/wiki/Madhava_of_Sangamagrama"visual="http://en.wikipedia.org/wiki/Madhava_of_Sangamagrama">Madhava</url>
438
+
<p>Write a function called myPi that will return an approximation of PI (3.14159…). Use the <urlhref="http://en.wikipedia.org/wiki/Madhava_of_Sangamagrama"visual="http://en.wikipedia.org/wiki/Madhava_of_Sangamagrama">Madhava</url>
<p>Write a function called <title_reference>fancySquare</title_reference> that will draw a square with fancy corners (sprites on the corners). You should
455
-
implement and use the <title_reference>drawSprite</title_reference> function from above. For an even more interesting look, how about adding small
454
+
<p>Write a function called fancySquare that will draw a square with fancy corners (sprites on the corners). You should
455
+
implement and use the drawSprite function from above. For an even more interesting look, how about adding small
0 commit comments