Skip to content
This repository has been archived by the owner on Jun 9, 2020. It is now read-only.
/ CIS-1051 Public archive

:squirrel: Introduction to Problem Solving and Programming coursework. Click README.ipynb if the file doesn't show up correctly. September 2016

Notifications You must be signed in to change notification settings

lablayers/CIS-1051

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 

Repository files navigation

{"nbformat_minor": 0, "cells": [{"source": "# CIS 1051 Introduction to Problem Solving and Programming (Python) Coursework\n\n## About this course\n\nThis class is taught at [Temple University](https://temple.edu/) as \"a good introduction for students who want to explore Python programming, and for beginners who feel that they need extra preparation.\" More information can be found by looking at the [CIS Bulletin](http://bulletin.temple.edu/courses/cis/) and searching for CIS 1051.\n\nThe book used is [Think Python 2e](http://greenteapress.com/wp/think-python-2e/) which is available [online for free](https://github.com/AllenDowney/ThinkPython2).\n\nThis class was taught using [Wing IDE](https://wingware.com/) but I ended up using a single Jupyter notebook hosted on [Azure Machine Learning Cloud](https://studio.azureml.net/) instead.\n\n\n## How did I end up here?\n\nA common question I got was \"HOW DID YOU END UP IN AN INTRO COURSE VICTOR???!?\"\n\nI tried to talk my way out of this class before my first semester of college started, but I was repeatedly told that this was the highest level CS classes I could take. This was due primarily to my unusual math circumstances despite getting a 4 on APCS and an extensive programming background. (Serously, common core screwed me over!)\n\nI ended up being bored in 1051 for a brief 3 weeks, and ended up helping the rest of the class on the first few labs after finishing mine before the instructor even showed up for class. After a few weeks of petitioning, I soon recieved a special exemption and ended up in the other intro-level course, CIS 1068 Program Design and Abstraction (Java), which was a class I already exempt from by scoring well on the APCS exam... oh well. \u00c2\u00af\\_(\u00e3\u0083\u0084)_/\u00c2\u00af\n\nYou can find my CIS 1068 coursework over at https://github.com/LabLayers/CIS-1068.\n\n## Content & Copyright\n\nBelow is every single line of code I've written for the class, all errors below are intentional. I'm releasing this code to public domain on an as-is basis. Do whatever you want with it really, but please note that any attempts at cheating or plagiarism may violate your institution's academic policy.\n\nI hope you get some value out of skimming through the first 3 weeks of code and seeing if CIS 1051 is right for you. Enjoy!", "cell_type": "markdown", "metadata": {"collapsed": true}}, {"execution_count": 1, "cell_type": "code", "source": "\"abc\"", "outputs": [{"execution_count": 1, "output_type": "execute_result", "data": {"text/plain": "'abc'"}, "metadata": {}}], "metadata": {"collapsed": false}}, {"execution_count": 2, "cell_type": "code", "source": "print(boo) # error is part of the lesson", "outputs": [{"ename": "NameError", "evalue": "name 'boo' is not defined", "traceback": ["\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[0;31mNameError\u001b[0m                                 Traceback (most recent call last)", "\u001b[0;32m<ipython-input-2-fc58d55a928f>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mboo\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;31m# error is part of the lesson\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", "\u001b[0;31mNameError\u001b[0m: name 'boo' is not defined"], "output_type": "error"}], "metadata": {"collapsed": false}}, {"execution_count": 3, "cell_type": "code", "source": "boo = \"I already know this\" + \" \" + \"shit\"\nprint(boo)", "outputs": [{"output_type": "stream", "name": "stdout", "text": "I already know this shit\n"}], "metadata": {"collapsed": false}}, {"execution_count": 4, "cell_type": "code", "source": "15", "outputs": [{"execution_count": 4, "output_type": "execute_result", "data": {"text/plain": "15"}, "metadata": {}}], "metadata": {"collapsed": false}}, {"execution_count": 5, "cell_type": "code", "source": "15**5", "outputs": [{"execution_count": 5, "output_type": "execute_result", "data": {"text/plain": "759375"}, "metadata": {}}], "metadata": {"collapsed": false}}, {"execution_count": 7, "cell_type": "code", "source": "8%3", "outputs": [{"execution_count": 7, "output_type": "execute_result", "data": {"text/plain": "2"}, "metadata": {}}], "metadata": {"collapsed": false}}, {"execution_count": 8, "cell_type": "code", "source": "foo = [1,2,3,\"bar\"]", "outputs": [], "metadata": {"collapsed": true}}, {"execution_count": 9, "cell_type": "code", "source": "foo[3]", "outputs": [{"execution_count": 9, "output_type": "execute_result", "data": {"text/plain": "'bar'"}, "metadata": {}}], "metadata": {"collapsed": false}}, {"execution_count": 10, "cell_type": "code", "source": "typeof(foo)", "outputs": [{"ename": "NameError", "evalue": "name 'typeof' is not defined", "traceback": ["\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[1;31mNameError\u001b[0m                                 Traceback (most recent call last)", "\u001b[1;32m<ipython-input-10-cac0bf65d853>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mtypeof\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mfoo\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m", "\u001b[1;31mNameError\u001b[0m: name 'typeof' is not defined"], "output_type": "error"}], "metadata": {"collapsed": false}}, {"execution_count": 11, "cell_type": "code", "source": "type(foo)", "outputs": [{"execution_count": 11, "output_type": "execute_result", "data": {"text/plain": "list"}, "metadata": {}}], "metadata": {"collapsed": false}}, {"execution_count": 12, "cell_type": "code", "source": "(5<10) == (5>3)", "outputs": [{"execution_count": 12, "output_type": "execute_result", "data": {"text/plain": "True"}, "metadata": {}}], "metadata": {"collapsed": false}}, {"execution_count": 13, "cell_type": "code", "source": "\"na\" * 50 + \"batman\"", "outputs": [{"execution_count": 13, "output_type": "execute_result", "data": {"text/plain": "'nanananananananananananananananananananananananananananananananananananananananananananananananananabatman'"}, "metadata": {}}], "metadata": {"collapsed": false}}, {"execution_count": 14, "cell_type": "code", "source": "import HTMLParser, urllib", "outputs": [{"ename": "ImportError", "evalue": "No module named 'HTMLParser'", "traceback": ["\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[1;31mImportError\u001b[0m                               Traceback (most recent call last)", "\u001b[1;32m<ipython-input-14-4e97a3c06a8f>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[1;32mimport\u001b[0m \u001b[0mHTMLParser\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0murllib\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m", "\u001b[1;31mImportError\u001b[0m: No module named 'HTMLParser'"], "output_type": "error"}], "metadata": {"collapsed": false}}, {"execution_count": 15, "cell_type": "code", "source": "import math", "outputs": [], "metadata": {"collapsed": true}}, {"execution_count": 16, "cell_type": "code", "source": "pi # error intentional", "outputs": [{"ename": "NameError", "evalue": "name 'pi' is not defined", "traceback": ["\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[1;31mNameError\u001b[0m                                 Traceback (most recent call last)", "\u001b[1;32m<ipython-input-16-68f7b1e53523>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mpi\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m", "\u001b[1;31mNameError\u001b[0m: name 'pi' is not defined"], "output_type": "error"}], "metadata": {"collapsed": false}}, {"execution_count": 17, "cell_type": "code", "source": "math.pi", "outputs": [{"execution_count": 17, "output_type": "execute_result", "data": {"text/plain": "3.141592653589793"}, "metadata": {}}], "metadata": {"collapsed": false}}, {"execution_count": 18, "cell_type": "code", "source": "pi = math.pi", "outputs": [], "metadata": {"collapsed": true}}, {"execution_count": 34, "cell_type": "code", "source": "pi", "outputs": [{"execution_count": 34, "output_type": "execute_result", "data": {"text/plain": "3.141592653589793"}, "metadata": {}}], "metadata": {"collapsed": false}}, {"execution_count": 35, "cell_type": "code", "source": "# got bored so I'm doing this\nimport os.path", "outputs": [], "metadata": {"collapsed": true}}, {"execution_count": 36, "cell_type": "code", "source": "os.path", "outputs": [{"execution_count": 36, "output_type": "execute_result", "data": {"text/plain": "<module 'posixpath' from '/home/nbuser/env3/lib/python3.4/posixpath.py'>"}, "metadata": {}}], "metadata": {"collapsed": false}}, {"execution_count": 37, "cell_type": "code", "source": "print (os.path.expanduser('~'))", "outputs": [{"output_type": "stream", "name": "stdout", "text": "/home/nbuser\n"}], "metadata": {"collapsed": false}}, {"execution_count": 38, "cell_type": "code", "source": "for i in enumerate('wawa'): print (i)", "outputs": [{"output_type": "stream", "name": "stdout", "text": "(0, 'w')\n(1, 'a')\n(2, 'w')\n(3, 'a')\n"}], "metadata": {"collapsed": false}}, {"source": "# Exercise 2.1.\n\nRepeating my advice from the previous chapter, whenever you learn a new feature, you should try it out in interactive mode and make errors on purpose to see what goes wrong.\n\n- We\u00e2\u0080\u0099ve seen that ``n = 42`` is legal. What about ``42 = n``?\n- How about ``x = y = 1``?\n- In some languages every statement ends with a semi-colon, ;. What happens if you put a semi-colon at the end of a Python statement?\n- What if you put a period at the end of a statement?\n- In math notation you can multiply x and y like this: xy. What happens if you try that in Python?\n\n# Exercise 2.2. \n\nPractice using the Python interpreter as a calculator:\n\n1. The volume of a sphere with radius r is 4 \u00cf\u0080r3. What is the volume of a sphere with radius 5?", "cell_type": "markdown", "metadata": {}}, {"execution_count": 40, "cell_type": "code", "source": "42 = n", "outputs": [{"ename": "SyntaxError", "evalue": "can't assign to literal (<ipython-input-40-600427bfcdb2>, line 1)", "traceback": ["\u001b[0;36m  File \u001b[0;32m\"<ipython-input-40-600427bfcdb2>\"\u001b[0;36m, line \u001b[0;32m1\u001b[0m\n\u001b[0;31m    42 = n\u001b[0m\n\u001b[0m          ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m can't assign to literal\n"], "output_type": "error"}], "metadata": {"collapsed": false}}, {"execution_count": 41, "cell_type": "code", "source": "x = y = 1", "outputs": [], "metadata": {"collapsed": true}}, {"execution_count": 43, "cell_type": "code", "source": "1 + 1;", "outputs": [], "metadata": {"collapsed": true}}, {"execution_count": 44, "cell_type": "code", "source": "ponk = 'buzz';", "outputs": [], "metadata": {"collapsed": true}}, {"execution_count": 46, "cell_type": "code", "source": "x = 5\ny = 20\nxy", "outputs": [{"ename": "NameError", "evalue": "name 'xy' is not defined", "traceback": ["\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[0;31mNameError\u001b[0m                                 Traceback (most recent call last)", "\u001b[0;32m<ipython-input-46-9bebc1b36b8e>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m      1\u001b[0m \u001b[0mx\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;36m5\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m      2\u001b[0m \u001b[0my\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;36m20\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 3\u001b[0;31m \u001b[0mxy\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", "\u001b[0;31mNameError\u001b[0m: name 'xy' is not defined"], "output_type": "error"}], "metadata": {"collapsed": false}}, {"execution_count": 48, "cell_type": "code", "source": "# Hi I think I overdid this\nimport math\ndef volume_of_sphere(radius):\n    volume = 4/3 * math.pi*radius**3\n    return (volume)\n    \nprint(volume_of_sphere(10))", "outputs": [{"output_type": "stream", "name": "stdout", "text": "4188.790204786391\n"}], "metadata": {"collapsed": false}}, {"execution_count": 2, "cell_type": "code", "source": "a = 'a'\nprint(a)", "outputs": [{"output_type": "stream", "name": "stdout", "text": "a\n"}], "metadata": {"collapsed": false}}, {"execution_count": 31, "cell_type": "code", "source": "1 + 2 * 3", "outputs": [{"execution_count": 31, "output_type": "execute_result", "data": {"text/plain": "7"}, "metadata": {}}], "metadata": {"collapsed": false}}, {"execution_count": 5, "cell_type": "code", "source": "# look hon, it's a list!!!!!\ntoppings=['cheese','pepperoni','salami','steak','pineapple','bacon']", "outputs": [], "metadata": {"collapsed": true}}, {"execution_count": 7, "cell_type": "code", "source": "print(toppings)", "outputs": [{"output_type": "stream", "name": "stdout", "text": "['cheese', 'pepperoni', 'salami', 'steak', 'pineapple', 'bacon']\n"}], "metadata": {"collapsed": false}}, {"execution_count": 9, "cell_type": "code", "source": "from collections import Counter\nprint(Counter(toppings))", "outputs": [{"output_type": "stream", "name": "stdout", "text": "Counter({'salami': 1, 'steak': 1, 'pineapple': 1, 'cheese': 1, 'pepperoni': 1, 'bacon': 1})\n"}], "metadata": {"collapsed": false}}, {"execution_count": 10, "cell_type": "code", "source": "toppings2=['cheese','pepperoni','pepperoni','pepperoni','pepperoni','pepperoni']\nprint(Counter(toppings2))", "outputs": [{"output_type": "stream", "name": "stdout", "text": "Counter({'pepperoni': 5, 'cheese': 1})\n"}], "metadata": {"collapsed": false}}, {"execution_count": 1, "cell_type": "code", "source": "# Shoutout to Wendy Urban for getting me out of this boring class! <3", "outputs": [], "metadata": {"collapsed": true}}], "nbformat": 4, "metadata": {"kernelspec": {"display_name": "Python 3", "name": "python3", "language": "python"}, "language_info": {"mimetype": "text/x-python", "nbconvert_exporter": "python", "version": "3.4.5", "name": "python", "file_extension": ".py", "pygments_lexer": "ipython3", "codemirror_mode": {"version": 3, "name": "ipython"}}}}

About

:squirrel: Introduction to Problem Solving and Programming coursework. Click README.ipynb if the file doesn't show up correctly. September 2016

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published