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
There is nothing exactly like <imgclass="nopadtb" src="/bjc-r/img/1-introduction/say-gossip.png" alt="say (gossip)" title="say (gossip)" /> or <imgclass="nopadtb" src="/bjc-r/img/1-introduction/say-gossip-for-3-secs.png" alt="say (gossip) for (3) secs" title="say (gossip) for (3) secs" /> on the AP Exam because they don't have sprites and speech balloons, but their way of showing this text to the user is
50
53
<preclass="inline">DISPLAY(gossip())</pre> if it's written as text or <imgclass="nopadtb" src="/bjc-r/img/1-introduction/display(gossip).png" alt="a white rounded rectangle containing first the word 'DISPLAY' in all caps and then a smaller white rectangle containing the word 'gossip' in lower case" title="a white rounded rectangle containing first the word 'DISPLAY' in all caps and then a smaller white rectangle containing the word 'gossip' in lower case" /> if it's shown as blocks.
<divclass="pseudop">The expression <imgclass="inline" src="/bjc-r/img/blocks/pick-random-1-to-10-full-size.png" alt="pick random (1) to (10)" title="pick random (1) to (10)" /> would be written as <preclass="inline">RANDOM(1, 10)</pre> or <imgclass="inline" src="/bjc-r/img/1-introduction/random-blocktran.png" alt="RANDOM(1, 10)" title="RANDOM(1, 10)" />. Every time you run this code, you will get a different random number between 1 and 10.</div>
155
+
<divclass="python" style="width:90%">
156
+
<ahref="#hint-python1" data-toggle="collapse" title="What would this look like in Python?">What would this look like in Python?</a>
157
+
<divid="hint-python1" class="collapse">
158
+
<pre><code>
159
+
from random import randint
160
+
randint(1, 10)</code></pre>
161
+
(Notice that the <code>random</code> library isn't loaded by default in Python and has to be imported. The <code>randint</code> function returns only integers. You can view the <ahref="https://docs.python.org/3/library/random.html" title="Python documentation: random" target="_blank">Python documentation</a> to learn more.)
<divclass="pseudop">The procedures <preclass="inline">move()</pre> and <preclass="inline">turn_clockwise()</pre> aren't built in to the AP's language so they are written in lower case like other programmer-defined procedures.</div>
130
-
<divclass="python">In Python, this would be written as:<br/><code>def pinwheel(number_of_branches):</code></div>
136
+
137
+
<divclass="python">
138
+
<ahref="#hint-python2" data-toggle="collapse" title="What would this look like in Python?">What would this look like in Python?</a>
<divclass="pseudop">Notice that the hat block, <imgclass="inline nopadtb" src="/bjc-r/img/1-introduction/pinwheel-hat-block.png" alt="pinwheel, branches: (number of branches)" title="pinwheel, branches: (number of branches)" />, would be written as <preclass="inline">PROCEDURE pinwheel(numberOfBranches)</pre>. The word <preclass="inline">PROCEDURE</pre> tells you that that line of the code is like a hat block; the variable name in the parentheses on that line is the input that the procedure takes.</div>
Add another input called <var>size</var> to control the input to the <em>first</em><code>move</code> block.<br/>
142
159
<imgclass="indent" src="/bjc-r/img/1-introduction/U1ImageVideoAddendum_img/U1L3-PinwheelwithInputs.png" width="700" alt="pinwheel, branches: (number of branches) size: (size) backup: (backup) hat block" title="pinwheel, branches: (number of branches) size: (size) backup: (backup) hat block"/>
143
160
</li>
144
161
<li>
@@ -181,7 +198,12 @@ <h3 class="box-head">Debugging Tip: Organizing Your Code</h3>
181
198
</div>
182
199
183
200
<divclass="examFullWidth">
184
-
<divclass="python" style="width:300px">In Python, this would be written as:<br/><code>pinwheel(6, 80, 20)</code></div>
201
+
<divclass="python">
202
+
<ahref="#hint-python4" data-toggle="collapse" title="What would this look like in Python?">What would this look like in Python?</a>
203
+
<divid="hint-python4" class="collapse">
204
+
<pre><code>pinwheel(6, 80, 20)</code></pre>
205
+
</div>
206
+
</div>
185
207
<divclass="ap-standard">AAP-3.A.5</div>
186
208
<divclass="pseudop">This instruction <imgclass="inline" src="/bjc-r/img/1-introduction/U1ImageVideoAddendum_img/U1L3-PinwheelwithInputs1.png" height="50" alt="setup; pinwheel, branches: (6) size: (80) backup: (20)" title=" pinwheel, branches: (6) size: (80) backup: (20)" /> would be written as <preclass="inline">Pinwheel(6, 80, 20)</pre> or <imgclass="nopadtb" src="/bjc-r/img/1-introduction/pinwheel-blocktran.png" alt="a white rounded rectangle containing first the word 'PINWHEEL' in all caps and then a smaller white rectangle containing the inputs '6, 80, 20'" title="a white rounded rectangle containing first the word 'PINWHEEL' in all caps and then a smaller white rectangle containing the inputs '6, 80, 20'" />.</div>
187
209
<p>You may hear people use the term "pseudocode" to refer to this pseudo-language used on the AP CS Principles exam, but it's <em>not</em> pseudocode. Pseudocode isn't a programming language at all, it's the use of normal human language to describe an algorithm.</p>
Copy file name to clipboardExpand all lines: cur/programming/2-complexity/1-variables-games/1-number-guessing-game.html
+8-2Lines changed: 8 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -66,8 +66,14 @@ <h3 class="box-head">Making a Script Variable</h3>
66
66
</div>
67
67
68
68
<divclass="examFullWidth">
69
-
<divclass="python">In Python, this would be written as:<br/><code>secretNumber = 7</code></div>
70
-
<divclass="ap-standard">AAP-1.B.2</div>
69
+
<divclass="python">
70
+
<ahref="#hint-python1" data-toggle="collapse" title="What would this look like in Python?">What would this look like in Python?</a>
71
+
<divid="hint-python1" class="collapse">
72
+
<pre><code>secretNumber = 7</code></pre>
73
+
(Python uses one equals sign to set the value of a variable.)
74
+
</div>
75
+
</div>
76
+
<divclass="ap-standard">AAP-1.B.2</div>
71
77
<divclass="pseudop">
72
78
<imgclass="inline" src="/bjc-r/img/2-complexity/set-secret-number-to-7.png" alt="set (secret number) to (7)" title="set (secret number) to (7)" /> would be written as <preclass="inline">secretNumber ← 7</pre> or <imgclass="nopadtb" src="/bjc-r/img/2-complexity/secret-number-assignment-blocktran.png" alt="a white rounded rectangle containing the text 'secretNumber ← 7'" title="a white rounded rectangle containing the text 'secretNumber ← 7'" />.
<divclass="pseudop">Notice that the procedure <preclass="inline">INPUT()</pre> accepts the value from the user and returns that input value, which is then assigned to the variable <preclass="inline">userResponse</pre> with the <preclass="inline">←</pre> syntax. In Snap<em>!</em>, this is just like how <code>answer</code> accepts a value from the user and reports it, and that report is what the computer <code>set</code>s the variable <var>user response</var> to.</div>
47
-
<divclass="python" style="width:90%">In Python, this would be written as:<br/><code>input = prompt("Why did the chicken cross the road?")
48
-
userResponse = input</code></div>
47
+
<divclass="python" style="width:90%">
48
+
<ahref="#hint-python1" data-toggle="collapse" title="What would this look like in Python?">What would this look like in Python?</a>
49
+
<divid="hint-python1" class="collapse">
50
+
<pre><code>
51
+
input = prompt("Why did the chicken cross the road?")
Copy file name to clipboardExpand all lines: cur/programming/2-complexity/1-variables-games/4-keeping-score.html
+6-1Lines changed: 6 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -50,7 +50,12 @@ <h3 class="box-head">Making a Global Variable</h3>
50
50
<li>Make the program <code>change</code> the score by 1 whenever the sprite is clicked.
51
51
<divclass="examFullWidth">
52
52
<divclass="pseudop">
53
-
<divclass="python">In Python, this would be written as:<br/><code>score = score + 1</code></div>
53
+
<divclass="python">
54
+
<ahref="#hint-python1" data-toggle="collapse" title="What would this look like in Python?">What would this look like in Python?</a>
55
+
<divid="hint-python1" class="collapse">
56
+
<pre><code>score = score + 1</code></pre>
57
+
</div>
58
+
</div>
54
59
<imgclass="inline nopadtb" src="/bjc-r/img/2-complexity/change-score-by-1.png" alt="change (score) by (1)" title="change (score) by (1)" /> (which means <imgsrc="/bjc-r/img/2-complexity/set-score-to-score-plus-one.png" alt="set(score) to (score+1)" title="set(score) to (score+1)">) would be written as <preclass="inline">score ← score + 1</pre> or <imgclass="inline" src="/bjc-r/img/2-complexity/score-increment-blocktran.png" alt="score ← score + 1" title="score ← score + 1" />.
0 commit comments