<html> <h1 id=“assignment-3-sunny-days”>Assignment 3: Sunny Days</h1> <p>Due: Thursday, 30 September 2021 at 11:59 p.m.</p> <p><img src=“https://www.cs.vassar.edu/~cs101/images/DSCF5442.jpeg” alt=“Sunrise/Sunset”></p> <h2 id=“introduction”>Introduction</h2> <p>We love sunny summer days, but the equinox is already behind us, and we know the hours of daylight are beginning to dwindle. In this assignment, we&#39;ll use our experience working with tables (in class and in lab) to process a table of solar (and lunar) temporal information and visualize how the amount of daylight varies over time.</p> <h2 id=“part-1-data”>Part 1: Data</h2> <p>Some kindly astronomers have shared a data set with us. They&#39;ve posted it as a <a href=“https://docs.google.com/spreadsheets/d/1L5fYmEgGmbpZcMA-Yz90L0ZyiMOdYq0VCHPdh8NyI5U/edit?usp=sharing”>Google sheet</a>.</p> <p><strong>Task</strong>: Copy the unique ID – the long string of letters, numbers, and hyphens – in the spreadsheet URL and use it to load the first sheet into a Pyret table, as you&#39;ve done in lab.</p> <p><strong>Note</strong>: We won&#39;t use all of the columns in this spreadsheet. That&#39;s perfectly normal when when working with real data.</p> <p><strong>Hint</strong>: Be sure you have the necessary

include

expressions!</p> <h2 id=“part-2-convert-times-to-minutes”>Part 2: Convert times to minutes</h2> <p>To compute the amount of daylight, we&#39;ll need to know the elapsed time between sunrise and sunset. It&#39;s complex to do this with times expressed as hours and minutes, e.g., 6:30, so we&#39;ll first write a function to convert a time to minutes.</p> <p><strong>Task</strong>: Design a function

time-str-to-minutes

that takes a time as a string (like those in the table) and converts it to the number of minutes since midnight.</p> <p><strong>Note</strong>: You will need to use the function <a href=“https://www.pyret.org/docs/latest/strings.html#%28part._strings_string-to-number%29”>

string-to-number

</a>. Despite its name, the output is <em>not</em> a number! It&#39;s

some

number if the string can be converted and

none

if it can&#39;t. You only need to worry about the

some

case. To get the number out, use

.value

:</p> <pre>

››› <span class="hljs-built_in">string</span>-<span class="hljs-keyword">to</span>-<span class="hljs-built_in">number</span>(<span class="hljs-string">"06"</span>)
<span class="hljs-keyword">some</span>(<span class="hljs-number">6</span>)
››› <span class="hljs-built_in">string</span>-<span class="hljs-keyword">to</span>-<span class="hljs-built_in">number</span>(<span class="hljs-string">"06"</span>).value
<span class="hljs-number">6</span>

</pre><p><strong>Hint</strong>: You may find it easier to do this if you first normalize the data so all times are in the same format. Currently some have two digits for the hours and some have one.</p> <p><strong>Hint</strong>: Since the times are strings, you may want to review the <a href=“https://www.pyret.org/docs/latest/strings.html”>documentation</a> listing the functions Pyret provides for working with strings. Some of these produce a

List

, which is a data type we haven&#39;t worked with yet – but the problem can be solved without using any of those functions.</p> <h2 id=“part-3-computing-hours-of-sunlight”>Part 3: Computing hours of sunlight</h2> <p>Now that we know how many minutes a particular time is since midnight, we can compute the difference between two times, such as our sunrise and sunset times.</p> <p><strong>Task</strong>: Design a function

hours-of-sunlight

that takes a row of the table and returns the number of hours of sunlight there are on that day.</p> <p><strong>Task</strong>: Build a new table with a column computed by your

hours-of-sunlight

function.</p> <h2 id=“part-4-visualization”>Part 4: Visualization</h2> <p>While we can look at the numbers we added to the table, it&#39;s nice to get an overview from a plot.</p> <p><strong>Task</strong>: Display a bar chart of the hours of sunlight.</p> <p>Unfortunately, none of the columns in the table give a particularly friendly label for the bars in the plot. Let&#39;s fix that!</p> <p><strong>Task</strong>: Add a column to the table giving a name for each row. This could be the full date or an abbreviated month name. Update your plot to use this column for its labels.</p> <h2 id=“assignment-guidelines”>Assignment guidelines</h2> <p>As with Assignment 2, you are expected to follow good Pyret style, including writing docstrings and examples for each function. Review the <a href=“https://www.cs.vassar.edu/~cs101/1/pyret.html”>Testing and Style Guidelines</a> and ask questions if anything&#39;s unclear!</p> <h2 id=“submit-assignment”>Submit assignment</h2> <ul> <li><p>Download your file (<em>File</em> -&gt; <em>Download</em>) and ensure it&#39;s named

asmt3-code.arr

.</p> </li> <li><p>Upload your assignment on Gradescope.</p> </li> </ul> <p><strong>Note</strong>: You can submit as many times as you want before the deadline. Only your latest submission will be graded.</p>

</html>