Skip to content

Instantly share code, notes, and snippets.

@josephtate
Last active October 27, 2018 07:12
Show Gist options
  • Save josephtate/f75162cfa6535ce007d73948409a9fd0 to your computer and use it in GitHub Desktop.
Save josephtate/f75162cfa6535ce007d73948409a9fd0 to your computer and use it in GitHub Desktop.
Jupyter Notebook for Programming Merit Badge
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## This is a Jupyter Notebook running Python 3\n",
"\n",
"These Notebooks are used by data scientists, educators, and hobbyists to explore data, teach, and play with the language.\n",
"\n",
"Python is also used in the following industries:\n",
"\n",
" * As a server side language for web development\n",
" * Data processing and analysis\n",
" * General Purpose Computing\n",
" \n",
"As you are working with this Notebook, pay attention to how you pass input to the program, and how output is displayed."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### The first section will convert Farenheit to Celcius\n",
"The formula to convert F to C is F minus 32 multiplied by 5/9.\n",
"\n",
" * What is 0F in C?\n",
" * What is 212F in C?"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Convert Farenheit to Celsius\n",
"def FtoC(nDegF):\n",
" return (nDegF - 32) * 5 / 9"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"FtoC(0)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"FtoC(212)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"FtoC(212)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"listF = range(-200, 600)\n",
"listC = map(FtoC, listF)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Create a function that will convert Celcius to Farenheit\n",
"\n",
"Reverse the process: C to F is (9/5 * C) + 32"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"def CtoF(nDegC):\n",
" nDegF = nDegC # modify this\n",
" return nDegF"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"CtoF(0)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"CtoF(-40)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"CtoF(100)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Do another Conversion\n",
"\n",
"Try Inches to centimeters, or dollars to Euros, or whatever you like"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"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.6"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment