diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..58461f2 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.ipynb_checkpoints \ No newline at end of file diff --git a/Week-5/01_basic_names.ipynb b/Week-5/01_basic_names.ipynb index ccfc8cc..ec0271a 100644 --- a/Week-5/01_basic_names.ipynb +++ b/Week-5/01_basic_names.ipynb @@ -20,11 +20,22 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 4, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "2.7182820533299275" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "roughly_e = ...\n", + "roughly_e = (1 + (1/99999999999))**99999999999\n", "roughly_e" ] }, @@ -39,19 +50,30 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 6, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "2.7182820533299275" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "n = ...\n", - "also_roughly_e = ...\n", + "n = 99999999999\n", + "also_roughly_e = (1+(1/n))**n\n", "also_roughly_e" ] } ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -65,7 +87,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.3" + "version": "3.9.12" } }, "nbformat": 4, diff --git a/Week-5/02_confusing_names.ipynb b/Week-5/02_confusing_names.ipynb index 97cbf8c..23dbf35 100644 --- a/Week-5/02_confusing_names.ipynb +++ b/Week-5/02_confusing_names.ipynb @@ -40,20 +40,20 @@ }, "outputs": [], "source": [ - "a = 1410\n", - "b = 1.989 * 10**30\n", - "c = 3\n", - "d = b / a\n", - "e = 3.14159\n", - "f = (d * 3/(4*e))**(1/3)\n", - "g = 4 * e * f**2\n", - "h = c * g" + "sun_density = 1410\n", + "sun_weight = 1.989 * 10**30\n", + "depth = 3\n", + "sun_volume = sun_weight / sun_density\n", + "pi = 3.14159\n", + "sun_radius = (sun_volume * 3/(4*pi))**(1/3)\n", + "sun_surface_area = 4 * pi * sun_radius**2\n", + "required_beer_volume = depth * sun_surface_area" ] } ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -67,7 +67,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.1" + "version": "3.9.12" } }, "nbformat": 4, diff --git a/Week-5/03_naming_errors.ipynb b/Week-5/03_naming_errors.ipynb index 42ceda9..51d1b93 100644 --- a/Week-5/03_naming_errors.ipynb +++ b/Week-5/03_naming_errors.ipynb @@ -44,20 +44,20 @@ "outputs": [], "source": [ "two = 2\n", - "four = two plus two" + "four = two + two" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "*Write your answer here, replacing this text.*" + "Python didn't recognize the value called 'plus' and was probably confused about it being there, and since 'plus' is a mathmatical operation, I replaced 'plus' with '+' which when ran, gave no errors." ] } ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -71,7 +71,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.1" + "version": "3.9.12" } }, "nbformat": 4, diff --git a/Week-5/04_basic_arithmetic.ipynb b/Week-5/04_basic_arithmetic.ipynb index 7673465..f805e95 100644 --- a/Week-5/04_basic_arithmetic.ipynb +++ b/Week-5/04_basic_arithmetic.ipynb @@ -21,11 +21,22 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 7, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "0.9999961853027344" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "..." + "1 - (2**2 / 2**20)" ] }, { @@ -39,21 +50,35 @@ "cell_type": "code", "execution_count": 9, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "29.0" + ] + }, + "execution_count": 9, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "1 - 2 ** 3 / 4 + 5 * 6" ] }, { "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, + "execution_count": 8, + "metadata": {}, "outputs": [], "source": [ - "# Your prediction here:\n", - "..." + "# Your prediction here: 29\n", + "# Order of Operations: (L-R)\n", + "# 2 ** 3 = 8\n", + "# 8 / 4 = 2\n", + "# 5 * 6 = 30\n", + "# 1 - 2 = -1\n", + "# -1 + 30 = 29" ] }, { @@ -67,7 +92,18 @@ "cell_type": "code", "execution_count": 10, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "-1805811300.4191697" + ] + }, + "execution_count": 10, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "1 - 2 ** (3 / 4 + 5 * 6)" ] @@ -76,7 +112,9 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "*Write your answer here, replacing this text.*" + "Prediction: The Value will be smaller, since everything in the parentheses will be done first, then that value will be the exponent for 2, aka 2 ^ value_in_parentheses, and then one will be added to that value(or subtracted depending on how you look at it), and will be shown.\n", + "\n", + "After cell execution: Right, and that is a rather large negative number." ] }, { @@ -94,17 +132,36 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 25, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "2.7182216960543433" + ] + }, + "execution_count": 25, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "..." + "n = 1000000000000\n", + "(1-(1/n))**-n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "When you enter in 10000 for n, you get the 'rough' 2.718, and by adding more zeros, you get a value more precise. However, after adding more than 12 zeros, that number seems to make the rounding happen in a way that the value is no longer 2.718, but 2.719 and increasing the more zeros added..." ] } ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -118,7 +175,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.3" + "version": "3.9.12" } }, "nbformat": 4, diff --git a/Week-5/05_maxmin.ipynb b/Week-5/05_maxmin.ipynb index a34bbbd..4b53b59 100644 --- a/Week-5/05_maxmin.ipynb +++ b/Week-5/05_maxmin.ipynb @@ -24,7 +24,8 @@ }, "outputs": [], "source": [ - "a + b + c - max(a, b, c) + min(a, b, c)" + "a + b + c - (max(a, b, c) + min(a, b, c))\n", + "# Originally: a + b + c - max(a, b, c) + min(a, b, c)" ] }, { @@ -38,15 +39,47 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 6, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "data": { + "text/plain": [ + "888" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# Testing the interesting function: a + b + c - max(a, b, c) + min(a, b, c)\n", + "\n", + "# Using the test input vals a = 4, b = 2, c = 7\n", + "\n", + "##a = 4\n", + "##b = 2\n", + "##c = 7\n", + "\n", + "a = 999\n", + "b = 345\n", + "c = 888\n", + "\n", + "a + b + c - (max(a, b, c) + min(a, b, c))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Code was not correct, would return a value that is not the middle one. By adding parentheses before the call of max and after the call of min, you can return a middle value of three variables every single time." + ] } ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -60,7 +93,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.3" + "version": "3.9.12" } }, "nbformat": 4, diff --git a/Week-5/06_rounding.ipynb b/Week-5/06_rounding.ipynb index 7e0e010..7be491b 100644 --- a/Week-5/06_rounding.ipynb +++ b/Week-5/06_rounding.ipynb @@ -23,11 +23,23 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 1, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "1.0" + ] + }, + "execution_count": 1, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "rounded = ...\n", + "# Round can take two parameters, the first is the number to round, while the second is the decimal places in which to round to.\n", + "rounded = round(1.23456789, 0)\n", "rounded" ] }, @@ -42,11 +54,23 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 2, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "1.235" + ] + }, + "execution_count": 2, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "less_rounded = ...\n", + "# Using round, with the second parameter as three, you get three decimal point precision.\n", + "less_rounded = round(1.23456789, 3)\n", "less_rounded" ] }, @@ -67,11 +91,22 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 3, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "71.0" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "sum_of_rounded_amounts = ...\n", + "sum_of_rounded_amounts = round(32.25, 0) + round(15.00, 0) + round(24.45, 0)\n", "sum_of_rounded_amounts" ] }, @@ -84,18 +119,29 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 4, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "72.0" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "rounded_sum = ...\n", + "rounded_sum = round((32.25 + 15.00 + 24.45), 0)\n", "rounded_sum" ] } ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -109,7 +155,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.3" + "version": "3.9.12" } }, "nbformat": 4,