{"nbformat":4,"nbformat_minor":0,"metadata":{"colab":{"name":"Assignment #1.ipynb","provenance":[],"collapsed_sections":[]},"kernelspec":{"name":"python3","display_name":"Python 3"}},"cells":[{"cell_type":"markdown","metadata":{"id":"LAqYJKA3tHeA"},"source":["# Assignment \\#1\n","\n","**Due:** Friday, October 16 at 11:59 pm PT\n","\n","**Objective:**\n","This assignment will give you experience using a Google Colab notebook to write text and code, including variables, mathematical operations, and string manipulations.\n","\n","**Instructions:**\n","1. This version of the assignment cannot be edited. To save an editable version, copy this Colab file to your individual class Google Drive folder (\"OCEAN 215 - Autumn '20 - {your name}\") by right clicking on this file and selecting \"Move to\".\n","2. Open the version you copied.\n","3. Complete the assignment by writing and executing text and code cells as specified. **For this assignment, do not use any features of Python that have not yet been discussed in the lessons or class sessions.**\n","4. When you're finished and are ready to submit the assignment, simply save the Colab file (\"File\" menu –> \"Save\") before the deadline, close the file, and keep it in your individual class Google Drive folder.\n","5. If you need more time, please see the section \"Late work policy\" in the syllabus for details.\n","\n","**Honor code:** In the space below, you can acknowledge and describe any assistance you've received on this assignment, whether that was from an instructor, classmate (either directly or on Piazza), and/or online resources other than official Python documentation websites like docs.python.org or numpy.org. Alternatively, if you prefer, you may acknowledge assistance at the relevant point(s) in your code using a Python comment (#)."]},{"cell_type":"markdown","metadata":{"id":"GdPsA50lJU_m"},"source":["*Acknowledge assistance here:*"]},{"cell_type":"markdown","metadata":{"id":"vbwSV0ivx8t8"},"source":["## Question 1 (8 points)\n","\n","Would it make the most sense to use a Colab notebook ('A'), Jupyter notebook ('B'), Python script ('C'), or the Python command line ('D') for the following purposes?\n","\n","To provide your answers, create variables below and assign to them a string with each answer. For instance:"]},{"cell_type":"code","metadata":{"id":"z_Chvuvzx-Vc"},"source":["question_1_part_6 = 'C' # this would indicate you've chosen a Python script for part (6) of the question"],"execution_count":null,"outputs":[]},{"cell_type":"markdown","metadata":{"id":"zkze1GpFzAf2"},"source":["Scenarios:\n","1. Exploring data you just collected from the ocean while conducting field work aboard a ship.\n","2. Quickly testing out a new Python function or package with a single line of code.\n","3. Writing sturdy code to regularly load and modify batches of data files that are generated in an identical format on a daily basis by a satellite.\n","4. Loading a fairly small data set, working up a preliminary analysis, and sharing the code and results with a teammate."]},{"cell_type":"code","metadata":{"id":"mEuH4FndzJA9"},"source":["# Provide your answers below:\n"],"execution_count":null,"outputs":[]},{"cell_type":"markdown","metadata":{"id":"romb5WJwDINk"},"source":["## Question 2 (6 points)\n","\n","Although the goal of OCEAN 215 is not to teach \"data science\" per se, we hope this course will give you a window into the possibilities offered by data analysis. If you find that you enjoy working with data and writing computer code, you might want to consider a career in academic research or data science. But what is data science, precisely? To better understand this rapidly-growing field, we would like you to read the following article (which should take about 15 minutes), then answer the questions below. There are no wrong answers, but please respond thoughtfully with 1-3 sentences for each (2 points each).\n","\n","**Article:** \"What is data science?\" *Thinkful.* https://www.thinkful.com/blog/what-is-data-science/. Read up until the \"Your Turn\" section. \n","\n","1. What data do you think you have generated today that might, at some point, be analyzed by a data scientist?\n","\n","2. Can you think of an oceanography data set that could be considered \"big data\"? Why would it be classified as such?\n","\n","3. The article describes how machine learning can be useful for making predictions and identifying relationships in data. Can you think of a research question or task in oceanography or your academic area of interest that might benefit from machine learning? Why might machine learning be particularly useful for that task?"]},{"cell_type":"markdown","metadata":{"id":"adanpZc9JSLB"},"source":["*Provide your responses here:*\n","\n"]},{"cell_type":"markdown","metadata":{"id":"Sd1TUGbrgwsb"},"source":["## Question 3 (10 points)\n","\n","Look at the following table of monthly weather averages in Honolulu, HI. (Source: [Google](https://www.google.com/search?rlz=1C5CHFA_enUS757US757&ei=oO90X-KsFdaU-gTg1paYCw&q=average+monthly+temperature+Honolulu&oq=average+monthly+temperature+Honolulu&gs_lcp=CgZwc3ktYWIQAzICCAAyBAgAEB4yBggAEAgQHjoECAAQRzoECAAQDVDCEVjIFWCoHGgAcAN4AIABPYgBdJIBATKYAQCgAQGqAQdnd3Mtd2l6yAEIwAEB&sclient=psy-ab&ved=0ahUKEwji_KHr4JHsAhVWip4KHWCrBbMQ4dUDCA0&uact=5))\n","\n","\\\\\n","\n","| Month | High T (˚F) | Low T (˚F) | \n","|----------|:-------------:|:-------------:|\n","| January | 81 | 65 |\n","| February | 81 | 65 |\n","| March | 82 | 67 |\n","| April | 83 | 68 |\n","| May | 85 | 69 |\n","| June | 86 | 72 |\n","| July | 87 | 73 |\n","| August | 88 | 73 |\n","| September| 88 | 73 |\n","| October | 87 | 72 |\n","| November | 84 | 70 |\n","| December | 82 | 67 |\n","\n","\\\\\n","\n","Answer the following questions using Python code. Please have your code output (print) something for each part. This output should start with the question part – e.g. print('Part 1:',...) – and include the specified lists or calculations and the answers to questions.\n","\n","1. Create and print a list containing the high temperatures for each month. What is the object type of the values inside of your list?\n","2. Create and print a new list with the original high temperatures converted into ˚C. If you do not know the conversion equation, feel free to look it up online, but acknowledge the source. What is the object type of the values inside of your new list?\n","3. What part of the conversion triggered this change in object type, and why? Print your answer (1 sentence).\n","4. In your new list from Part 2, replace the temperature in December with a temperature that is 1˚C colder. Print this list.\n","5. Create a list containing the low temperatures for each month. \n","6. Calculate the average low temperature (˚F).\n","7. Sort the low temperature list from low to high.\n"]},{"cell_type":"code","metadata":{"id":"zohLDb7awjqW"},"source":["# Provide your answers below:\n"],"execution_count":null,"outputs":[]},{"cell_type":"markdown","metadata":{"id":"L0B9RK4r6Yix"},"source":["## Question 4 (9 points)\n","Challenger Deep, at a depth of 36,200 feet, is known as the deepest part of the ocean (source: [NOAA Ocean Facts](https://oceanservice.noaa.gov/facts/oceandepth.html)). Answer the following questions using Python code. Please have your code output (print) the solutions to each part, including the units! Start your output with the question part, e.g. print('Part 1:',...). If you do not know a conversion factor, feel free to look it up online, but acknowledge the source.\n","\n","1. Convert the depth of Challenger Deep to miles.\n","2. Convert the depth of Challenger Deep to km.\n","3. Find the pressure in atm at the bottom of Challenger Deep. (Hint: 1 atm is approximately 10.33 m)\n","4. Convert the pressure to Pa. (Hint: 1 atm is approximately 101325 Pa)\n","5. Convert the pressure to dbar. (Interesting fact: depths in oceanographic data are often specified in dbar instead of meters. Despite pressure not being the same thing as depth, the pressure at 1000 m depth is nearly – but not exactly – equivalent to 1000 dbar. You can confirm this near-equivalence by comparing your answer here to Part 2.)\n","6. If a particle is sinking at a constant rate from the surface to the bottom of the ocean above Challenger Deep at 0.1 mm/s, how many days will it take to reach the bottom?"]},{"cell_type":"code","metadata":{"id":"Dc9yJ5FX64DU"},"source":["# Provide your answers below:\n"],"execution_count":null,"outputs":[]},{"cell_type":"markdown","metadata":{"id":"1xFc_ymI_gqB"},"source":["## Question 5 (10 points)\n","Ribosomal RNA (rRNA) gene sequencing is often used in phylogenetic research. Each sequence is made up of combinations of 4 different nucleobases, adenine (A), cytosine (C), guanine (G), and uracil (U). Every species of bacteria and archaea has a slightly-unique version of its 16s rRNA gene. This means that 16s rRNA can be targeted to classify what marine bacteria are present in a given parcel of seawater.\n","\n","In the code box below, there are two strings containing different DNA gene sequences, which differ from RNA in that they contain thymine (T) nucleobases rather than uracil (U). Answer the following questions using Python. Please have your code output (print) the solutions to each, including any strings you are asked to create or slice. Start your output with the question part, e.g. print('Part 1:',...).\n","\n","1. How many nucleobases are in each of the sequences?\n","2. How many times does adenine (A) occur in each of the sequences?\n","3. Do four thymine (T) nucleobases ever occur side-by-side in either of the sequences? Provide your answers as booleans.\n","4. Create and print two new rRNA sequences by replacing the thymine (T) bases with uracil (U) bases in both DNA sequences.\n","5. Slice and print the first 24 nucleobases from the new rRNA sequences. How many of each nucleobase (A,C,G,U) are in each of these shorter sequences?"]},{"cell_type":"code","metadata":{"id":"NOVKnmep__Bq"},"source":["# Keep these starting lines of code – these may not be changed:\n","DNA1 = 'GGGGGGCAGCAGTGGGGAATATTGGGCAATGGACGAAAGTCTGACCCAGCCATGCCGCGTGTGTGAAGAAGGCTCTAGGGTTGTAATGCACTTTAAGTAGGGAGGAAAGGTTGTGTGTTAATAGCACATAGCTGTGACGTTACCTACAGAATAAGCACCGGCTAACTCCGTGCCAGCAGCCGCGGTAATACGGAGGGTGCAAGCGTTAATCGGAATTACTGGGCGTAAAGCGCGCGTAGGCGGTTATTTAAGCTAGATGTGAAAGCCCAGGGCTCAACCTTGGAATTGCATTTAGAACTGGGTAGCTAGAGTACAAGAGAGGGTGGTGGAATTTCCAGTGTAGCGGTGAAATGCGTAGAGATTGGAAGGAACATCAGTGGCGAAGGCGGCCACCTGGATTGATACTGACGCTGAGGTGCGAAAGCGTGGGGAGCAAACAGGATTAGATACCCCAGTAGTCCT'\n","DNA2 = 'GGGGCGCAGCAGTGGGGAATATTGCACAATGGGCGAAAGCCTGATGCAGCCATGCCGCGTGTGTGAAGAAGGCCTTCGGGTTGTAAAGCGCTTTCAGTTGTGAGGAAAGGGGTGTAGTTAATAGCTACATCCTGTGACGTTAGCAACAGAAGAAGCACCGGCTAACTTCGTGCCAGCAGCCTCGGTAATACGAGGGGTGCAAGCGTTAATCGGAATTACTGGGCGTAAAGCGTTCGTAGGCGGTTTGTTAAGCAAGATGTGAAAGCCCTGGGCTCAACCTGGGAACTGCATTTTGAACTGGCAAACTAGAGTACTGTAGAGGGTGGTGGAATTTCCAGTGTAGCGGTGAAATGCGTAGAGATTGGAAGGAACATCAGTGGCGAAGGCGGCCACCTGGACAGATACTGACGCTGAGGAACGAAAGCGTGGGGAGCAAACAGGATTAGATACCCTAGTAGTCTG'\n","\n","# Provide your answers below:\n"],"execution_count":null,"outputs":[]},{"cell_type":"markdown","metadata":{"id":"FQQ68HPc_uoo"},"source":["## Question 6 (7 points)\n","\n","In the code box below, there is a list of [rorqual whales](https://www.britannica.com/animal/rorqual) containing both their common name, their scientific name as a sub-list separated into genus and species, and their estimated populations (source: [The International Whaling Commission](https://iwc.int/status)). As before, begin your answers with the question part, e.g. print('Part 1:',...).\n","\n","1. How many species are in this list?\n","2. Replace each of the inner scientific name sub-lists with a single string containing both the genus and the species separated by a space. Convert the population estimate strings to integers and replace them in the list. Make these changes \"in-place,\" that is, without creating a new list. Print the updated list.\n","3. Remove the information about the Antarctic minke whale from the end of the list and insert it at the beginning of the list. Ensure that the overall format of the list stays the same."]},{"cell_type":"code","metadata":{"id":"30akt8mh_25u"},"source":["# Keep these starting lines of code – these may not be changed:\n","rorqual_whales = [['Blue whale',['Balaenoptera','musculus'],'8000'],\n"," ['Bryde\\'s whale',['Balaenoptera','brydei'],'90000'],\n"," ['Common minke whale',['Balaenoptera','acutorostrata'],'200000'],\n"," ['Fin whale',\t['Balaenoptera','physalus'],'90000'],\n"," ['Sei whale',\t['Balaenoptera','borealis'],'50000'],\n"," ['Antarctic minke whale',['Balaenoptera', 'bonaerensis'],'510000']]\n","\n","# Provide your answers below:\n"],"execution_count":null,"outputs":[]},{"cell_type":"markdown","metadata":{"id":"WNXRVUUy45Xw"},"source":["## Question 7 (optional, for extra credit: 5 points)\n","\n","This is a coding puzzle. Write **4 or fewer lines of code** (to follow the 3 lines provided) such that, after executing the code:\n","* the variable 'x' will be equal to 44,\n","* the variable 'y' will be equal to 4,\n","* and the variable 'z' will be equal to 40.\n","\n","Here's the catch: the code you write may contain mathematical operations (for instance, z = x + y), but **may not contain any numbers** and **may not add a variable to itself** (for instance, z = x + x)."]},{"cell_type":"code","metadata":{"id":"TwKT6CXczLjf"},"source":["# Keep these starting lines of code – these may not be changed:\n","x = 4\n","y = 12\n","z = 'Hello'\n","\n","# Write your own code below:\n"],"execution_count":null,"outputs":[]}]}