{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Practice Problems\n", "### Lecture 2\n", "\n", "\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_02\n", " \n", "Turn in this notebook on Canvas. " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "1. Conceptual\n", " - Insert a markdown cell into your practice notebook and answer the questions:\n", " - Why are descriptive variable names useful?\n", " - What are _reserved words_ and why can't you use them as variable names?\n", "\n", "2. Variables\n", " - Insert a code cell into your practice notebook\n", " - In it, define a variable that stores the value of pi (3.1415)\n", "\t- Define a variable called **radius**, that stores any floating point number (radius)\n", "\t- Define a string that stores \"is the circumference of a circle with radius\" \n", "\n", "3. Operations\n", " - Insert another code cell into your practice notebook. \n", "\t- Calculate the circumference of a circle using the variables you defined earlier and store the answer in a separate variable.\n", " - print your new variable.\n", "\n", "4. Changing variable types\n", " - Convert all your variables (**circumference** and **radius**) into strings\n", " - Use the + operator to add them together to make this string:\n", "\t\t**circumference** is the circumference of a circle with radius of **radius** \n", " - **boldface** words are your new strings]. \n", "\n", "5. Strings and string operation\n", "\t- Define a variable with the value:\n", "\t\t\t\"Scripps Institution of Oceanography\"\n", "\t- Print out the first 7 characters \n", " - print indices 8 to 19\n", "\t- Print index 23 to the end\n", " \n", "6. Putting it all together\n", "\n", " - Create an integer variable **depth** and set it to 6\n", " - Create a string variable **planet** and set it to “Earth”\n", " - convert the variable **depth** into a string \n", " - Create a variable **ocean_depth** and set it to the string: “The average ocean depth on Earth is 6 km” by using the variables depth and planet instead of Earth and 6\n", " - print out the variable **ocean_depth**" ] }, { "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 }