{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Practice Problems\n", "### Lecture 3\n", "Answer each number in a separate cell\n", "\n", "Rename this notebook with your last name, first initial and the (2 digit) lecture number. \n", " \n", " ex. Cych_B_03\n", " \n", "Turn in this notebook on Canvas. " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Oceans and Continents\n", "1. Conceptual \n", " - Give an example of when you would use a set\n", " - Give an example of when you would use a tuple\n", " - Give an example of when you would use range( ) \n", "2. Lists\n", " - Create an empty list called _oceans_\n", " - append all the oceans to the list \n", " - print the ocean at **index** 3 in the list \n", " - print the last element of your list. \n", " - make a shallow copy of _oceans_ called _seas_ and a deep copy of _oceans_ called _big_water_. Try to modify the copies. Verify that the shallow copy refers to the same underlying object while the deep copy makes an independent object. \n", " - Apply the method **.sort()** to one of your copies and then print the copy\n", "3. range( )\n", " - Use the function **range( )** to create a list with a “range” of numbers from 0 up to (but not including) 100, increment by any number (less than 100) and print the results.\n", "4. Tuples\n", " - Create a tuple called _continents_ with the continents as elements.\n", " - Attempt to change the second **element** (not index) in place (this should throw and error). \n", " - print out the third **element** (not index) in the tuple\n", "5. Sets\n", " - create a set from the _oceans_ list you created earlier.\n", " - print out the set of oceans " ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.7" } }, "nbformat": 4, "nbformat_minor": 2 }