INF110-Projects/Week-5/01_basic_names.ipynb
cdez 4fc499169b Added Files, Changed Folder Names, AND MUCH MORE!
++ Week 5 Folder
++ Week 5 Homework
+- Week 2 Folder Name
2022-09-28 09:23:14 -07:00

73 lines
1.8 KiB
Text

{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Names in Python"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**Question 1.** A famous fact in mathematics is that\n",
"\n",
"$$(1 + \\frac{1}{n})^{n}$$\n",
"\n",
"gets very close to the number $e$, which is roughly $2.718$, when $n$ is large. Use this fact to compute an approximation to $e$, called `roughly_e`. Your approximation should be correct to at least 5 decimal places."
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"roughly_e = ...\n",
"roughly_e"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**Question 2.** In the previous question, you might have noticed that you had to type in the value of $n$ twice when you tried different values (once as `1/n` and once as `**n`). You might have even accidentally used 2 different values.\n",
"\n",
"Redo the code in the cell below, giving your estimate of $e$ the name `also_roughly_e`. Instead of writing the value of $n$ twice, give it the name `n` in your Python code, and then use that name in your expression for `also_roughly_e`."
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"n = ...\n",
"also_roughly_e = ...\n",
"also_roughly_e"
]
}
],
"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.8.3"
}
},
"nbformat": 4,
"nbformat_minor": 1
}