Skip to content

Commit 0ffedd2

Browse files
authored
Merge pull request #251 from jdeisenberg/master
Add exercise to chapter 1.
2 parents 615c450 + b10f23c commit 0ffedd2

1 file changed

Lines changed: 55 additions & 1 deletion

File tree

pretext/GeneralIntro/Exercises.ptx

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,59 @@
11
<?xml version="1.0"?>
22
<exercises xml:id="general-intro_exercises">
33
<title>Exercises</title>
4-
<p>There are not currently any exercises for this chapter. It is included here as a subchapter for consistency with other chapters.</p>
4+
<exercise>
5+
<statement>
6+
<p>
7+
This exercise will let you practice displaying information. Write a program that prints following:
8+
</p>
9+
<ul>
10+
<li>Your name.</li>
11+
<li>Your favorite color.</li>
12+
<li>Your favorite word, in double quotes.</li>
13+
<li>Your favorite poem, at least three lines long (If your favorite poem is longer than ten lines, give only the first three to ten lines.)</li>
14+
<li>The author of the poem. The name should be indented four spaces and preceded by a hyphen and a space. If you don't know who wrote the poem, use “Anonymous” as the author.</li>
15+
</ul>
16+
17+
<p>Use complete sentences and blank lines for readability. To print a blank line, use:</p>
18+
<program language="python">
19+
<input>
20+
print()
21+
</input>
22+
</program>
23+
24+
<p>The parentheses are required, even though there is nothing between them. If you don't believe me, leave them out and see what the output looks like!</p>
25+
26+
<p>Here is what the output of a possible solution looks like:</p>
27+
28+
<console><output>
29+
My name is Juana Fulano.
30+
My favorite color is purple.
31+
My favorite word is "giraffe".
32+
33+
My favorite poem:
34+
35+
Greet the dawn,
36+
Rise with the sun.
37+
Rejoice in the sunset
38+
When day is done.
39+
- Anonymous
40+
</output></console>
41+
</statement>
42+
<program interactive="activecode" language="python" xml:id="ch01_ex1_editor">
43+
<input>
44+
45+
</input>
46+
</program>
47+
48+
<hint>
49+
<p>You can use either single quotes or double quotes to enclose a string in Python.
50+
That lets you do something like this:
51+
</p>
52+
<program language="python">
53+
<input>
54+
print('He said "Hello!" to me.')
55+
</input>
56+
</program>
57+
</hint>
58+
</exercise>
559
</exercises>

0 commit comments

Comments
 (0)