Skip to content

Commit

Permalink
add jupyternotebook
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuwq0 committed Sep 7, 2024
1 parent 2112339 commit f9b4b20
Showing 1 changed file with 177 additions and 0 deletions.
177 changes: 177 additions & 0 deletions docs/exercises/00_introduction_python101.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# PyEarth: A Python Introduction to Earth Science\n",
"## Class 1 Exercises"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Exercise 1: Variables and Data Types\n",
"\n",
"Create variables for the following Earth-related information:\n",
"\n",
"- Name of our planet\n",
"- Earth's radius in kilometers\n",
"- Earth's average surface temperature in Celsius\n",
"- Whether Earth has a moon (use a boolean)\n",
"- A list of Earth's layers (inner core, outer core, mantle, crust)\n",
"\n",
"Print all these variables."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"vscode": {
"languageId": "plaintext"
}
},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Exercise 2: Arithmetic Operations\n",
"\n",
"Calculate the following:\n",
"\n",
"- The circumference of Earth (use the radius from Exercise 1 and the formula 2 * π * r)\n",
"- The difference between the boiling point of water (100°C) and Earth's average surface temperature\n",
"- The number of times Earth's diameter (use the radius from Exercise 1) can fit between Earth and the Moon (average distance: 384,400 km)\n",
"\n",
"Print the results."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"vscode": {
"languageId": "plaintext"
}
},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Exercise 3: Control Flow\n",
"\n",
"Create a function that takes a temperature in Celsius and returns a description of Earth's temperature:\n",
"\n",
"- If temp < 0: \"Earth is in an ice age\"\n",
"- If 0 <= temp < 15: \"Earth is cool\"\n",
"- If 15 <= temp < 25: \"Earth is moderate\"\n",
"- If temp >= 25: \"Earth is warm\"\n",
"\n",
"Test your function with different temperatures."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"vscode": {
"languageId": "plaintext"
}
},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Exercise 4: Lists and Loops\n",
"\n",
"Given the list of planets: `[\"Mercury\", \"Venus\", \"Earth\", \"Mars\", \"Jupiter\", \"Saturn\", \"Uranus\", \"Neptune\"]`\n",
"\n",
"Write a loop that prints each planet's name and its position from the Sun.\n",
"\n",
"Example output: \"Mercury is the 1st planet from the Sun\""
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"vscode": {
"languageId": "plaintext"
}
},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"### Exercise 5: Functions\n",
"\n",
"Write a function that converts kilometers to miles (1 km = 0.621371 miles).\n",
"Use this function to convert Earth's radius to miles."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"vscode": {
"languageId": "plaintext"
}
},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Exercise 6: Dictionaries\n",
"\n",
"Create a dictionary for Earth with the following keys and values:\n",
"\n",
"- name: \"Earth\"\n",
"- radius_km: (use the value from Exercise 1)\n",
"- has_moon: (use the value from Exercise 1)\n",
"- atmosphere_composition: {\"nitrogen\": 78, \"oxygen\": 21, \"other\": 1}\n",
"\n",
"Write a function that takes this dictionary and prints a summary of Earth's properties.\n",
"\n",
"Example output:\n",
"\n",
"\"Earth has a radius of X km and has/doesn't have a moon. Its atmosphere is composed of 78% nitrogen, 21% oxygen, and 1% other gases.\""
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"vscode": {
"languageId": "plaintext"
}
},
"outputs": [],
"source": []
}
],
"metadata": {
"language_info": {
"name": "python"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

0 comments on commit f9b4b20

Please sign in to comment.