Skip to content

Instantly share code, notes, and snippets.

@NaimKabir
Last active August 19, 2019 11:07
Show Gist options
  • Save NaimKabir/ed31b590367425a8471bc34e2ed8fbfc to your computer and use it in GitHub Desktop.
Save NaimKabir/ed31b590367425a8471bc34e2ed8fbfc to your computer and use it in GitHub Desktop.
Toy code snippet to demonstrate a naive debuggable function
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"def get_remainder(dividend, divisor):\n",
" # This function returns the remainder from an integer\n",
" # division operation\n",
" integer_quotient = round(dividend / divisor)\n",
" remainder = dividend - (integer_quotient*divisor)\n",
" return remainder"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Let's try it out:"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1\n"
]
}
],
"source": [
"print(get_remainder(7, 6))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Lookin' pretty good... let's try another:"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"-3\n"
]
}
],
"source": [
"print(get_remainder(9, 6))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Well that's not good."
]
}
],
"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.5"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment