-- IPYNB Checkpoints ++ Git Ignore File for IPYNB Checkpoints +- Week 5 Homework Files
75 lines
2.3 KiB
Text
75 lines
2.3 KiB
Text
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"## Confusing Names"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"**Question 1.** Some physicists and computer scientists were partying late one night, and they decided to figure out roughly how much beer it would take to cover the whole surface of the Sun 3 meters deep. They found the following facts:\n",
|
|
"\n",
|
|
"1. The average density (mass per volume) of the Sun is 1410 $\\texttt{kg}/\\texttt{m}^3$.\n",
|
|
"2. The Sun weighs $1.989 \\times 10^{30} \\texttt{kg}$.\n",
|
|
"3. The Sun's volume is its weight divided by its density.\n",
|
|
"4. The Sun is roughly a sphere.\n",
|
|
"5. The radius of a sphere is $(\\texttt{volume} \\times \\frac{3}{4 \\times \\pi})^{1/3}$\n",
|
|
"6. $\\pi$ is roughly 3.14159.\n",
|
|
"7. The surface area of a sphere is $4 \\times \\pi \\times \\texttt{radius}^2$.\n",
|
|
"\n",
|
|
"They wrote code in the next cell to compute the answer. But the next morning, they couldn't figure out what their code did, because none of the names made sense. To help clarify their code, replace the names used in the next cell with appropriate names chosen from the following list:\n",
|
|
"\n",
|
|
"* `required_beer_volume`\n",
|
|
"* `sun_radius`\n",
|
|
"* `sun_volume`\n",
|
|
"* `sun_surface_area`\n",
|
|
"* `sun_density`\n",
|
|
"* `pi`\n",
|
|
"* `sun_weight`"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 4,
|
|
"metadata": {
|
|
"collapsed": true
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"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 (ipykernel)",
|
|
"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.9.12"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 1
|
|
}
|