Skip to content

Instantly share code, notes, and snippets.

@twavv
Created May 28, 2017 20:31
Show Gist options
  • Save twavv/90c34e7e1c97e95fe0fe93171183f2ea to your computer and use it in GitHub Desktop.
Save twavv/90c34e7e1c97e95fe0fe93171183f2ea to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"metadata": {},
"cell_type": "raw",
"source": "###nus begin section"
},
{
"metadata": {},
"cell_type": "markdown",
"source": "## Python Math Basics"
},
{
"metadata": {
"autograde_tag": "square",
"trusted": false,
"collapsed": true
},
"cell_type": "code",
"source": "###nus autograde_id square_integer\n###nus assignment_name Square an Integer\ndef square(x):\n \"\"\"Returns the square of an integer x.\"\"\"\n ###nus begin solution\n return -1\n ###nus end solution",
"execution_count": 1,
"outputs": []
},
{
"metadata": {
"trusted": true,
"collapsed": true
},
"cell_type": "code",
"source": "###nus autograde_id even_integer\n###nus assignment_name Return Evenness of an Integer\ndef even(x):\n \"\"\"Returns true if the integer x is even and false otherwise.\"\"\"\n ###nus begin solution\n return (x % 2)\n ###nus end solution",
"execution_count": null,
"outputs": []
},
{
"metadata": {
"trusted": false,
"collapsed": true
},
"cell_type": "raw",
"source": "###nus end section"
},
{
"metadata": {},
"cell_type": "raw",
"source": "###nus begin section"
},
{
"metadata": {},
"cell_type": "markdown",
"source": "## Python String Basics"
},
{
"metadata": {
"autograde_tag": "square",
"trusted": false,
"collapsed": true
},
"cell_type": "code",
"source": "###nus autograde_id substring\n###nus assignment_name Substring\ndef substr(s, a, b):\n \"\"\"Returns the subsection of a string from letters a through b.\n Ex. substr(\"hello world\", 1, 5) returns \"ello\".\"\"\"\n ###nus begin solution\n return s[a:b]\n ###nus end solution",
"execution_count": 1,
"outputs": []
},
{
"metadata": {
"trusted": false,
"collapsed": true
},
"cell_type": "raw",
"source": "###nus end section"
}
],
"metadata": {
"kernelspec": {
"name": "python3",
"display_name": "Python 3",
"language": "python"
},
"language_info": {
"version": "3.5.2",
"mimetype": "text/x-python",
"nbconvert_exporter": "python",
"file_extension": ".py",
"name": "python",
"codemirror_mode": {
"version": 3,
"name": "ipython"
},
"pygments_lexer": "ipython3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment