Skip to content

Commit

Permalink
removed search from keys?
Browse files Browse the repository at this point in the history
  • Loading branch information
kcaylor committed Sep 12, 2024
1 parent 89a3f81 commit 70e3cba
Show file tree
Hide file tree
Showing 74 changed files with 709 additions and 709 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ <h3 class="anchored" data-anchor-id="task-1-list-operations">Task 1: List Operat
<li>Remove the second fruit from the list.</li>
<li>Print the final list.</li>
</ol>
<div id="41757afa" class="cell" data-execution_count="1">
<div id="69086262" class="cell" data-execution_count="1">
<div class="sourceCode cell-code" id="cb1"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="co"># Example code for instructor</span></span>
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a>fruits <span class="op">=</span> [<span class="st">"apple"</span>, <span class="st">"banana"</span>, <span class="st">"cherry"</span>]</span>
<span id="cb1-3"><a href="#cb1-3" aria-hidden="true" tabindex="-1"></a><span class="bu">print</span>(<span class="st">"Original list:"</span>, fruits)</span>
Expand Down Expand Up @@ -512,7 +512,7 @@ <h3 class="anchored" data-anchor-id="task-2-dictionary-operations">Task 2: Dicti
<li>Update the quantity of an existing item.</li>
<li>Print the final inventory.</li>
</ol>
<div id="faaf5697" class="cell" data-execution_count="2">
<div id="e41e5832" class="cell" data-execution_count="2">
<div class="sourceCode cell-code" id="cb3"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="co"># Example code for instructor</span></span>
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a>inventory <span class="op">=</span> {</span>
<span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a> <span class="st">"apples"</span>: <span class="dv">50</span>,</span>
Expand Down Expand Up @@ -549,7 +549,7 @@ <h3 class="anchored" data-anchor-id="task-3-creating-and-manipulating-sets">Task
<li>Find and print the intersection of the two sets.</li>
<li>Add a new element to the <code>evens</code> set.</li>
</ol>
<div id="4ae48aa8" class="cell" data-execution_count="3">
<div id="12023436" class="cell" data-execution_count="3">
<div class="sourceCode cell-code" id="cb5"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a><span class="co"># Example code for instructor</span></span>
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a>evens <span class="op">=</span> {<span class="dv">2</span>, <span class="dv">4</span>, <span class="dv">6</span>, <span class="dv">8</span>, <span class="dv">10</span>}</span>
<span id="cb5-3"><a href="#cb5-3" aria-hidden="true" tabindex="-1"></a>odds <span class="op">=</span> {<span class="dv">1</span>, <span class="dv">3</span>, <span class="dv">5</span>, <span class="dv">7</span>, <span class="dv">9</span>}</span>
Expand Down Expand Up @@ -583,7 +583,7 @@ <h3 class="anchored" data-anchor-id="task-4-set-operations-vs.-list-operations">
<li>Use a list comprehension to remove duplicates.</li>
<li>Print the results of both methods.</li>
</ol>
<div id="c5bd9559" class="cell" data-execution_count="4">
<div id="73c60b9e" class="cell" data-execution_count="4">
<div class="sourceCode cell-code" id="cb7"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a><span class="co"># Example code for instructor</span></span>
<span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a>numbers <span class="op">=</span> [<span class="dv">1</span>, <span class="dv">2</span>, <span class="dv">2</span>, <span class="dv">3</span>, <span class="dv">3</span>, <span class="dv">3</span>, <span class="dv">4</span>, <span class="dv">4</span>, <span class="dv">5</span>]</span>
<span id="cb7-3"><a href="#cb7-3" aria-hidden="true" tabindex="-1"></a></span>
Expand Down
18 changes: 9 additions & 9 deletions docs/course-materials/answer-keys/3b_control_flows-key.html
Original file line number Diff line number Diff line change
Expand Up @@ -470,10 +470,10 @@ <h3 class="anchored" data-anchor-id="task-1-simple-weather-advice">Task 1: Simpl
<li>Otherwise, print “Enjoy the pleasant weather!”</li>
</ul></li>
</ol>
<div id="8fcfd9d4" class="cell" data-execution_count="1">
<div id="41527b68" class="cell" data-execution_count="1">
<div class="sourceCode cell-code" id="cb2"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a>temperature <span class="op">=</span> <span class="dv">20</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div id="af90ac3a" class="cell" data-execution_count="2">
<div id="858298a6" class="cell" data-execution_count="2">
<div class="sourceCode cell-code" id="cb3"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="cf">if</span> temperature <span class="op">&gt;</span> <span class="dv">25</span>:</span>
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>(<span class="st">"It's a hot day, stay hydrated!"</span>)</span>
<span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a><span class="cf">else</span>:</span>
Expand All @@ -497,10 +497,10 @@ <h3 class="anchored" data-anchor-id="task-2-grade-classifier">Task 2: Grade Clas
<li>Below 60: “F”</li>
</ul></li>
</ol>
<div id="0fa96194" class="cell" data-execution_count="3">
<div id="9cb8ac94" class="cell" data-execution_count="3">
<div class="sourceCode cell-code" id="cb5"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a>score <span class="op">=</span> <span class="dv">85</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div id="681d2d84" class="cell" data-execution_count="4">
<div id="c22eeb39" class="cell" data-execution_count="4">
<div class="sourceCode cell-code" id="cb6"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a><span class="cf">if</span> score <span class="op">&gt;=</span> <span class="dv">90</span>:</span>
<span id="cb6-2"><a href="#cb6-2" aria-hidden="true" tabindex="-1"></a> grade <span class="op">=</span> <span class="st">'A'</span></span>
<span id="cb6-3"><a href="#cb6-3" aria-hidden="true" tabindex="-1"></a><span class="cf">elif</span> score <span class="op">&gt;=</span> <span class="dv">80</span>:</span>
Expand Down Expand Up @@ -528,7 +528,7 @@ <h3 class="anchored" data-anchor-id="task-3-counting-sheep">Task 3: Counting She
<li>Use a for loop with the range() function</li>
<li>Print each number followed by “sheep”</li>
</ol>
<div id="ac4e2185" class="cell" data-execution_count="5">
<div id="4a2b688c" class="cell" data-execution_count="5">
<div class="sourceCode cell-code" id="cb8"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a><span class="cf">for</span> i <span class="kw">in</span> <span class="bu">range</span>(<span class="dv">1</span>,<span class="dv">6</span>):</span>
<span id="cb8-2"><a href="#cb8-2" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>(<span class="ss">f"</span><span class="sc">{</span>i<span class="sc">}</span><span class="ss"> sheep"</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stdout">
Expand All @@ -548,10 +548,10 @@ <h3 class="anchored" data-anchor-id="task-4-sum-of-numbers">Task 4: Sum of Numbe
<li>Use a for loop with the range() function to add each number to <code>total</code></li>
<li>After the loop, print the total</li>
</ol>
<div id="bf7e7dbc" class="cell" data-execution_count="6">
<div id="c652055c" class="cell" data-execution_count="6">
<div class="sourceCode cell-code" id="cb10"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true" tabindex="-1"></a>total <span class="op">=</span> <span class="dv">0</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div id="df502019" class="cell" data-execution_count="7">
<div id="54c48e7d" class="cell" data-execution_count="7">
<div class="sourceCode cell-code" id="cb11"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb11-1"><a href="#cb11-1" aria-hidden="true" tabindex="-1"></a><span class="cf">for</span> i <span class="kw">in</span> <span class="bu">range</span>(<span class="dv">1</span>,<span class="dv">11</span>):</span>
<span id="cb11-2"><a href="#cb11-2" aria-hidden="true" tabindex="-1"></a> total <span class="op">=</span> total <span class="op">+</span> i</span>
<span id="cb11-3"><a href="#cb11-3" aria-hidden="true" tabindex="-1"></a></span>
Expand All @@ -573,10 +573,10 @@ <h3 class="anchored" data-anchor-id="task-5-countdown">Task 5: Countdown</h3>
<li>After each print, decrease the countdown by 1</li>
<li>When the countdown reaches 0, print “Blast off!”</li>
</ol>
<div id="8d98af07" class="cell" data-execution_count="8">
<div id="d22808e6" class="cell" data-execution_count="8">
<div class="sourceCode cell-code" id="cb13"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb13-1"><a href="#cb13-1" aria-hidden="true" tabindex="-1"></a>countdown <span class="op">=</span> <span class="dv">5</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div id="8e326ed1" class="cell" data-execution_count="9">
<div id="63c51f2b" class="cell" data-execution_count="9">
<div class="sourceCode cell-code" id="cb14"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb14-1"><a href="#cb14-1" aria-hidden="true" tabindex="-1"></a><span class="cf">while</span> countdown <span class="op">&gt;</span> <span class="dv">0</span>:</span>
<span id="cb14-2"><a href="#cb14-2" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>(countdown)</span>
<span id="cb14-3"><a href="#cb14-3" aria-hidden="true" tabindex="-1"></a> <span class="co"># (-= is a python syntax shortcut inherited from C)</span></span>
Expand Down
10 changes: 5 additions & 5 deletions docs/course-materials/answer-keys/3d_pandas_series-key.html
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ <h2 class="anchored" data-anchor-id="resources">Resources</h2>
<section id="setup" class="level2">
<h2 class="anchored" data-anchor-id="setup">Setup</h2>
<p>First, let’s import the necessary libraries and create a sample Series.</p>
<div id="eaa5aa46" class="cell" data-execution_count="1">
<div id="87821e66" class="cell" data-execution_count="1">
<div class="sourceCode cell-code" id="cb1"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="im">import</span> pandas <span class="im">as</span> pd</span>
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a><span class="im">import</span> numpy <span class="im">as</span> np</span>
<span id="cb1-3"><a href="#cb1-3" aria-hidden="true" tabindex="-1"></a></span>
Expand All @@ -463,7 +463,7 @@ <h2 class="anchored" data-anchor-id="exercise-1-creating-a-series">Exercise 1: C
<blockquote class="blockquote">
<p>apple: $0.5, banana: $0.3, cherry: $1.0, date: $1.5, elderberry: $2.0</p>
</blockquote>
<div id="6a4d01cf" class="cell" data-execution_count="2">
<div id="adcccb4f" class="cell" data-execution_count="2">
<div class="sourceCode cell-code" id="cb3"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="co"># Create a Series called 'prices' with the same index as 'fruits'</span></span>
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a><span class="co"># Use these prices: apple: $0.5, banana: $0.3, cherry: $1.0, date: $1.5, elderberry: $2.0</span></span>
<span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a>prices <span class="op">=</span> pd.Series([<span class="fl">0.5</span>, <span class="fl">0.3</span>, <span class="fl">1.0</span>, <span class="fl">2.5</span>, <span class="fl">3.0</span>], index<span class="op">=</span>fruits.values, name<span class="op">=</span><span class="st">'Prices'</span>)</span>
Expand All @@ -486,7 +486,7 @@ <h2 class="anchored" data-anchor-id="exercise-2-series-operations">Exercise 2: S
<li>Find the most expensive fruit.</li>
<li>Apply a 10% discount to all fruits priced over 1.0.</li>
</ol>
<div id="8f1b1f16" class="cell" data-execution_count="3">
<div id="68eaa5f2" class="cell" data-execution_count="3">
<div class="sourceCode cell-code" id="cb5"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a><span class="co"># 1. Calculate the total price of all fruits</span></span>
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a>total_price <span class="op">=</span> prices.<span class="bu">sum</span>()</span>
<span id="cb5-3"><a href="#cb5-3" aria-hidden="true" tabindex="-1"></a></span>
Expand Down Expand Up @@ -522,7 +522,7 @@ <h2 class="anchored" data-anchor-id="exercise-3-series-analysis">Exercise 3: Ser
<li>How many fruits cost less than $1.0?</li>
<li>What is the price range (difference between max and min prices)?</li>
</ol>
<div id="4ba0fe11" class="cell" data-execution_count="4">
<div id="9b08582b" class="cell" data-execution_count="4">
<div class="sourceCode cell-code" id="cb7"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a><span class="co"># 1. Calculate the average price of the fruits</span></span>
<span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a>average_price <span class="op">=</span> prices.mean()</span>
<span id="cb7-3"><a href="#cb7-3" aria-hidden="true" tabindex="-1"></a></span>
Expand Down Expand Up @@ -550,7 +550,7 @@ <h2 class="anchored" data-anchor-id="exercise-4-series-manipulation">Exercise 4:
<li>Remove ‘banana’ from both Series.</li>
<li>Sort both Series by fruit name (alphabetically).</li>
</ol>
<div id="7e88c3db" class="cell" data-execution_count="5">
<div id="9cae837a" class="cell" data-execution_count="5">
<div class="sourceCode cell-code" id="cb9"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a><span class="co"># 1. Add 'fig' to both Series (price: $1.2)</span></span>
<span id="cb9-2"><a href="#cb9-2" aria-hidden="true" tabindex="-1"></a>fruits <span class="op">=</span> pd.concat([fruits, pd.Series([<span class="st">'fig'</span>], name<span class="op">=</span><span class="st">'Fruits'</span>)])</span>
<span id="cb9-3"><a href="#cb9-3" aria-hidden="true" tabindex="-1"></a>prices <span class="op">=</span> pd.concat([prices, pd.Series([<span class="fl">1.2</span>], index<span class="op">=</span>[<span class="st">'fig'</span>], name<span class="op">=</span><span class="st">'Prices'</span>)])</span>
Expand Down
Loading

0 comments on commit 70e3cba

Please sign in to comment.