├── requirements.txt ├── notebooks ├── images │ ├── favicon-0.png │ ├── favicon.png │ ├── globe_poor.png │ ├── en_logged_in.png │ ├── en_login_page.png │ ├── en_submit_page.png │ ├── hn_home_page.png │ ├── defender_rocket.png │ ├── django_it_worked.png │ ├── ed_news_homepage.png │ ├── en_minimal_style.png │ ├── en_profile_page.png │ ├── en_registerhtml.png │ ├── basemap_simpletest.png │ ├── en_password_change.png │ ├── en_username_header.png │ ├── pygame_empty_window.png │ ├── defender_rocket_50px.png │ ├── defender_ship_appears.png │ ├── en_admin_userprofile.png │ ├── en_homepage_bootstrap.png │ ├── earthquake_plot_titled.png │ └── en_homepage_responsive.png ├── multiplying.py ├── my_templates │ ├── include_jquery.html │ ├── index.tpl │ ├── intro_python_base.tpl │ ├── intro_python_header.html │ ├── index_body.html │ └── navbar.html ├── css │ ├── show_all_style.css │ ├── nb3_overrides.css │ ├── site_styles.css │ ├── bootstrap_overrides.css │ └── non-responsive.css ├── js │ ├── nbconvert_js.js │ ├── show_hide_output.js │ ├── html5shiv.js │ ├── respond.min.js │ └── bootstrap.min.js ├── rocket.py ├── programming_competencies.ipynb ├── exceptions.ipynb ├── testing.ipynb ├── hello_world.ipynb ├── index.ipynb ├── syllabus.ipynb ├── web_apps.ipynb ├── resources.ipynb ├── programming_environment.ipynb ├── programming_environment_osx.ipynb ├── programming_environment_linux.ipynb ├── programming_environment_extras.ipynb ├── programming_environment_windows.ipynb ├── contents.ipynb └── introducing_functions.ipynb ├── .gitignore ├── scripts ├── highlight_inline_code.sh ├── build_index.py ├── convert_home_links.sh ├── remove_input_references.py ├── create_common_html.sh ├── build_html_pages.sh ├── show_hide_output.py ├── highlight_code.py └── build_all_exercises_page.py ├── LICENSE.md ├── tests └── test_links.py ├── README.md └── html_resources └── index.html /requirements.txt: -------------------------------------------------------------------------------- 1 | ipython[all]==1.1.0 2 | requests==2.0.0 3 | matplotlib==1.3.1 4 | -------------------------------------------------------------------------------- /notebooks/images/favicon-0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ehmatthes/intro_programming/HEAD/notebooks/images/favicon-0.png -------------------------------------------------------------------------------- /notebooks/images/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ehmatthes/intro_programming/HEAD/notebooks/images/favicon.png -------------------------------------------------------------------------------- /notebooks/images/globe_poor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ehmatthes/intro_programming/HEAD/notebooks/images/globe_poor.png -------------------------------------------------------------------------------- /notebooks/images/en_logged_in.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ehmatthes/intro_programming/HEAD/notebooks/images/en_logged_in.png -------------------------------------------------------------------------------- /notebooks/images/en_login_page.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ehmatthes/intro_programming/HEAD/notebooks/images/en_login_page.png -------------------------------------------------------------------------------- /notebooks/images/en_submit_page.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ehmatthes/intro_programming/HEAD/notebooks/images/en_submit_page.png -------------------------------------------------------------------------------- /notebooks/images/hn_home_page.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ehmatthes/intro_programming/HEAD/notebooks/images/hn_home_page.png -------------------------------------------------------------------------------- /notebooks/images/defender_rocket.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ehmatthes/intro_programming/HEAD/notebooks/images/defender_rocket.png -------------------------------------------------------------------------------- /notebooks/images/django_it_worked.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ehmatthes/intro_programming/HEAD/notebooks/images/django_it_worked.png -------------------------------------------------------------------------------- /notebooks/images/ed_news_homepage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ehmatthes/intro_programming/HEAD/notebooks/images/ed_news_homepage.png -------------------------------------------------------------------------------- /notebooks/images/en_minimal_style.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ehmatthes/intro_programming/HEAD/notebooks/images/en_minimal_style.png -------------------------------------------------------------------------------- /notebooks/images/en_profile_page.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ehmatthes/intro_programming/HEAD/notebooks/images/en_profile_page.png -------------------------------------------------------------------------------- /notebooks/images/en_registerhtml.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ehmatthes/intro_programming/HEAD/notebooks/images/en_registerhtml.png -------------------------------------------------------------------------------- /notebooks/images/basemap_simpletest.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ehmatthes/intro_programming/HEAD/notebooks/images/basemap_simpletest.png -------------------------------------------------------------------------------- /notebooks/images/en_password_change.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ehmatthes/intro_programming/HEAD/notebooks/images/en_password_change.png -------------------------------------------------------------------------------- /notebooks/images/en_username_header.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ehmatthes/intro_programming/HEAD/notebooks/images/en_username_header.png -------------------------------------------------------------------------------- /notebooks/images/pygame_empty_window.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ehmatthes/intro_programming/HEAD/notebooks/images/pygame_empty_window.png -------------------------------------------------------------------------------- /notebooks/images/defender_rocket_50px.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ehmatthes/intro_programming/HEAD/notebooks/images/defender_rocket_50px.png -------------------------------------------------------------------------------- /notebooks/images/defender_ship_appears.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ehmatthes/intro_programming/HEAD/notebooks/images/defender_ship_appears.png -------------------------------------------------------------------------------- /notebooks/images/en_admin_userprofile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ehmatthes/intro_programming/HEAD/notebooks/images/en_admin_userprofile.png -------------------------------------------------------------------------------- /notebooks/images/en_homepage_bootstrap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ehmatthes/intro_programming/HEAD/notebooks/images/en_homepage_bootstrap.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | notes/* 2 | *~ 3 | *.ipynb_checkpoints 4 | *# 5 | notebooks/*.html* 6 | notebooks/__pycache__ 7 | notebooks/my_templates/ignored_templates 8 | -------------------------------------------------------------------------------- /notebooks/images/earthquake_plot_titled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ehmatthes/intro_programming/HEAD/notebooks/images/earthquake_plot_titled.png -------------------------------------------------------------------------------- /notebooks/images/en_homepage_responsive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ehmatthes/intro_programming/HEAD/notebooks/images/en_homepage_responsive.png -------------------------------------------------------------------------------- /notebooks/multiplying.py: -------------------------------------------------------------------------------- 1 | # Save as multiplying.py 2 | 3 | def double(x): 4 | return 2*x 5 | 6 | def triple(x): 7 | return 3*x 8 | 9 | def quadruple(x): 10 | return 4*x 11 | -------------------------------------------------------------------------------- /notebooks/my_templates/include_jquery.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /notebooks/my_templates/index.tpl: -------------------------------------------------------------------------------- 1 | {%- block header -%} 2 | {% include "intro_python_header.html" %} 3 | {%- endblock header -%} 4 | 5 | {% block body %} 6 | 7 | {% include "navbar.html" %} 8 | {% include "index_body.html" %} 9 | 10 | {%- endblock body %} 11 | 12 | {% block footer %} 13 | {% include "include_jquery.html" %} 14 | 15 | {% endblock footer %} 16 | 17 | -------------------------------------------------------------------------------- /notebooks/css/show_all_style.css: -------------------------------------------------------------------------------- 1 | /* Style sheet for pages that should start out with all output 2 | displayed, such as Mapping Global Earthquake Activity. */ 3 | 4 | /* --- Show/ Hide output --- */ 5 | /* Start out with show buttons not displayed. */ 6 | button.show_output { 7 | display: none; 8 | } 9 | 10 | button.hide_output { 11 | display: inline; 12 | } 13 | 14 | /* Start out with output shown. */ 15 | div.output { 16 | display: inline; 17 | } 18 | -------------------------------------------------------------------------------- /notebooks/my_templates/intro_python_base.tpl: -------------------------------------------------------------------------------- 1 | {%- extends 'basic.tpl' -%} 2 | {% from 'mathjax.tpl' import mathjax %} 3 | 4 | 5 | {%- block header -%} 6 | {% include "my_templates/intro_python_header.html" %} 7 | {%- endblock header -%} 8 | 9 | {% block body %} 10 | 11 | {% include "my_templates/navbar.html" %} 12 |
13 | {{ super() }} 14 |
15 | 16 | {%- endblock body %} 17 | 18 | {% block footer %} 19 | {% include "my_templates/include_jquery.html" %} 20 | 21 | {% endblock footer %} -------------------------------------------------------------------------------- /notebooks/js/nbconvert_js.js: -------------------------------------------------------------------------------- 1 | init_mathjax = function() { 2 | if (window.MathJax) { 3 | // MathJax loaded 4 | MathJax.Hub.Config({ 5 | tex2jax: { 6 | inlineMath: [ ['$','$'], ["\\(","\\)"] ], 7 | displayMath: [ ['$$','$$'], ["\\[","\\]"] ] 8 | }, 9 | displayAlign: 'left', // Change this to 'center' to center equations. 10 | "HTML-CSS": { 11 | styles: {'.MathJax_Display': {"margin": 0}} 12 | } 13 | }); 14 | MathJax.Hub.Queue(["Typeset",MathJax.Hub]); 15 | } 16 | } 17 | init_mathjax(); 18 | -------------------------------------------------------------------------------- /scripts/highlight_inline_code.sh: -------------------------------------------------------------------------------- 1 | # This script runs through all the html files in notebooks/, and 2 | # modifies tags to 3 | # Rationale: 4 | # Inline code blocks are much easier to recognize when they are highlighted, 5 | # in a manner similar to stackoverflow. 6 | 7 | printf "\nHighlighting inline code blocks...\n" 8 | 9 | old_string='' 10 | new_string='' 11 | 12 | if [ -e "../notebooks/" ] 13 | then 14 | find ../notebooks -iname '*.html' | xargs sed -i "s/$old_string/$new_string/g" 15 | else 16 | find notebooks -iname '*.html' | xargs sed -i "s/$old_string/$new_string/g" 17 | fi 18 | 19 | 20 | printf " Highlighted inline code blocks.\n" 21 | -------------------------------------------------------------------------------- /scripts/build_index.py: -------------------------------------------------------------------------------- 1 | from jinja2 import Environment, FileSystemLoader 2 | 3 | # Load index template. 4 | my_template_path = '/srv/projects/intro_programming/intro_programming/notebooks/my_templates' 5 | my_template_base_path = '/srv/projects/intro_programming/intro_programming/notebooks' 6 | ipython_template_path = '/srv/projects/intro_programming/venv/lib/python3.4/site-packages/IPython/nbconvert/templates/html' 7 | 8 | my_loader = FileSystemLoader( 9 | [my_template_path, my_template_base_path, ipython_template_path]) 10 | env = Environment(loader=my_loader) 11 | 12 | index_template = my_loader.load(env, 'index.tpl') 13 | 14 | # Render template to file. 15 | notebooks_path = '/srv/projects/intro_programming/intro_programming/notebooks/' 16 | filepath = notebooks_path + 'index.html' 17 | with open(filepath, 'w') as f: 18 | f.write(index_template.render()) 19 | -------------------------------------------------------------------------------- /scripts/convert_home_links.sh: -------------------------------------------------------------------------------- 1 | # This script runs through all the html files in notebooks/, and 2 | # modifies index.html links to ./ 3 | # Rationale: 4 | # ipynb files need to link to index notebook. 5 | # But html sites are better off linking to root, which will call index.html. 6 | # Calling index.html leads user to end up using two names for the index page, 7 | # which is confusing for tracking. 8 | 9 | printf "\nConverting home links to ./ now...\n" 10 | 11 | old_string="href='index.html'" 12 | old_string_2='href="index.html"' 13 | new_string="href='.\/'" 14 | 15 | if [ -e "../notebooks/" ] 16 | then 17 | find ../notebooks -iname '*.html' | xargs sed -i "s/$old_string/$new_string/" 18 | find ../notebooks -iname '*.html' | xargs sed -i "s/$old_string_2/$new_string/" 19 | else 20 | find notebooks -iname '*.html' | xargs sed -i "s/$old_string/$new_string/" 21 | find notebooks -iname '*.html' | xargs sed -i "s/$old_string_2/$new_string/" 22 | fi 23 | 24 | printf " Converted home links.\n" 25 | -------------------------------------------------------------------------------- /notebooks/rocket.py: -------------------------------------------------------------------------------- 1 | from math import sqrt 2 | 3 | class Rocket(): 4 | # Rocket simulates a rocket ship for a game, 5 | # or a physics simulation. 6 | 7 | def __init__(self, x=0, y=0): 8 | # Each rocket has an (x,y) position. 9 | self.x = x 10 | self.y = y 11 | 12 | def move_rocket(self, x_increment=0, y_increment=1): 13 | # Move the rocket according to the paremeters given. 14 | # Default behavior is to move the rocket up one unit. 15 | self.x += x_increment 16 | self.y += y_increment 17 | 18 | def get_distance(self, other_rocket): 19 | # Calculates the distance from this rocket to another rocket, 20 | # and returns that value. 21 | distance = sqrt((self.x-other_rocket.x)**2+(self.y-other_rocket.y)**2) 22 | return distance 23 | 24 | 25 | class Shuttle(Rocket): 26 | # Shuttle simulates a space shuttle, which is really 27 | # just a reusable rocket. 28 | 29 | def __init__(self, x=0, y=0, flights_completed=0): 30 | super().__init__(x, y) 31 | self.flights_completed = flights_completed 32 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) {{2013}} {{Eric Matthes}} 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /notebooks/css/nb3_overrides.css: -------------------------------------------------------------------------------- 1 | /* Overrides of notebook CSS for static HTML export */ 2 | body { 3 | overflow: visible; 4 | padding: 8px; 5 | } 6 | 7 | div#notebook { 8 | overflow: visible; 9 | border-top: none; 10 | } 11 | 12 | @media print { 13 | div.cell { 14 | display: block; 15 | page-break-inside: avoid; 16 | } 17 | div.output_wrapper { 18 | display: block; 19 | page-break-inside: avoid; 20 | } 21 | div.output { 22 | display: block; 23 | page-break-inside: avoid; 24 | } 25 | } 26 | 27 | /* Site doesn't use input or output prompts. */ 28 | 29 | div.prompt { 30 | min-width: 0ex; 31 | padding: 0em; 32 | } 33 | 34 | /* Most relevant on earthquake visualization now. */ 35 | img { 36 | max-width: 100%; 37 | } 38 | 39 | /* Use bootstrap-style headings. */ 40 | div.rendered_html h1 { 41 | font-weight: 500; 42 | font-size: 36px; 43 | } 44 | 45 | div.rendered_html h2 { 46 | font-weight: 500; 47 | font-size: 30px; 48 | } 49 | 50 | div.rendered_html h3 { 51 | font-weight: 500; 52 | font-size: 24px; 53 | } 54 | 55 | div.rendered_html h4 { 56 | font-weight: 500; 57 | font-size: 18px; 58 | } 59 | -------------------------------------------------------------------------------- /notebooks/css/site_styles.css: -------------------------------------------------------------------------------- 1 | /* Styles for the overall site. 2 | These styles are unrelated to bootstrap, etc. */ 3 | 4 | /* --- Show/ Hide output --- */ 5 | /* Start out with hide buttons not displayed. */ 6 | button.hide_output { 7 | display: none; 8 | } 9 | 10 | button.hide_output, button.show_output { 11 | width: 100px; 12 | margin: 5px 0px 0px 0px; 13 | } 14 | 15 | button.show_output_all { 16 | margin-right: 10px; 17 | } 18 | 19 | /* Start out with output hidden. */ 20 | div.output { 21 | display: none; 22 | } 23 | 24 | 25 | /* Twitter share button */ 26 | div.twitter-share-button { 27 | float: right; 28 | margin-top: 14px; 29 | margin-right: -40px; 30 | } 31 | 32 | /* Twitter follow button */ 33 | div.twitter-follow-button { 34 | float: right; 35 | margin-top: 14px; 36 | margin-right: 15px; 37 | border: solid 0px black; 38 | } 39 | 40 | 41 | /* Highlighting code */ 42 | div.highlighted_code_line { 43 | background-color: #e3e3e3; 44 | } 45 | 46 | code.inline_code { 47 | background-color: #f0f0f0; 48 | padding: 2px; 49 | margin: 1px; 50 | } 51 | 52 | 53 | /* all_exercises_challenges */ 54 | h3.contents_level_two { 55 | margin-left: 20px; 56 | margin-bottom: 0px; 57 | } 58 | 59 | pre code { 60 | display: block; 61 | border-radius: 4px; 62 | } -------------------------------------------------------------------------------- /notebooks/js/show_hide_output.js: -------------------------------------------------------------------------------- 1 | // Show all output 2 | $(document).ready(function(){ 3 | $("button.show_output_all").click(function(){ 4 | // Make all output visible 5 | $("div.output").show(); 6 | // Make sure all buttons toggled to 'hide output' 7 | $("button.show_output").hide(); 8 | $("button.hide_output").show(); 9 | }); 10 | }); 11 | 12 | // Hide all output 13 | $(document).ready(function(){ 14 | $("button.hide_output_all").click(function(){ 15 | // Hide all output 16 | $("div.output").hide(); 17 | // Make sure all buttons toggled to 'show output' 18 | $("button.show_output").show(); 19 | $("button.hide_output").hide(); 20 | }); 21 | }); 22 | 23 | // Show single output 24 | $(document).ready(function(){ 25 | $("button.show_output").click(function(){ 26 | var id_num = $(this).attr('target') 27 | $("#output_"+id_num).show(); 28 | $("button#show_output_"+id_num).hide(); 29 | $("button#hide_output_"+id_num).show(); 30 | }); 31 | }); 32 | 33 | // Hide single output 34 | $(document).ready(function(){ 35 | $("button.hide_output").click(function(){ 36 | var id_num = $(this).attr('target') 37 | $("#output_"+id_num).hide(); 38 | $("button#hide_output_"+id_num).hide(); 39 | $("button#show_output_"+id_num).show(); 40 | }); 41 | }); -------------------------------------------------------------------------------- /scripts/remove_input_references.py: -------------------------------------------------------------------------------- 1 | # This script removes the input reference numbers from html pages. 2 | # They play a useful role in scientific notebooks, but they are really 3 | # just visual clutter in this project. 4 | # Could be an nbconvert setting, but it's an easy enough scripting job. 5 | 6 | import os 7 | import sys 8 | 9 | print("\nStripping input reference numbers from code cells...") 10 | 11 | # Find all files to work with. 12 | path_to_notebooks = '/srv/projects/intro_programming/intro_programming/notebooks/' 13 | filenames = [] 14 | for filename in os.listdir(path_to_notebooks): 15 | if '.html' in filename and filename != 'index.html': 16 | filenames.append(filename) 17 | 18 | # one file for testing: 19 | #filenames = ['hello_world.html'] 20 | 21 | for filename in filenames: 22 | 23 | f = open(path_to_notebooks + filename, 'r') 24 | lines = f.readlines() 25 | f.close() 26 | 27 | f = open(path_to_notebooks + filename, 'wb') 28 | for line in lines: 29 | # Unwanted lines have opening and closing div on same line, 30 | # with input reference number between them. 31 | if ('
' in line 32 | and '
' in line): 33 | # Don't write this line. 34 | continue 35 | else: 36 | # Regular line, write it. 37 | f.write(line.encode('utf-8')) 38 | 39 | f.close() 40 | 41 | print(" Stripped input reference numbers.\n") 42 | 43 | -------------------------------------------------------------------------------- /notebooks/programming_competencies.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "metadata": { 3 | "name": "programming_competencies" 4 | }, 5 | "nbformat": 3, 6 | "nbformat_minor": 0, 7 | "worksheets": [ 8 | { 9 | "cells": [ 10 | { 11 | "cell_type": "markdown", 12 | "metadata": {}, 13 | "source": [ 14 | "Programming Competencies\n", 15 | "===\n", 16 | "What should your goals be if you want to become a strong programmer?" 17 | ] 18 | }, 19 | { 20 | "cell_type": "markdown", 21 | "metadata": {}, 22 | "source": [ 23 | "Programming Environment\n", 24 | "---\n", 25 | "- Know the strengths and weaknesses of your OS and distribution.\n", 26 | "- Know how to rebuild your system from scratch, when you break your build." 27 | ] 28 | }, 29 | { 30 | "cell_type": "markdown", 31 | "metadata": {}, 32 | "source": [ 33 | "Programming Essentials\n", 34 | "---\n", 35 | "- Know the basics in your language.\n", 36 | "- Continue to develop your programming toolbox, within your language of choice." 37 | ] 38 | }, 39 | { 40 | "cell_type": "markdown", 41 | "metadata": {}, 42 | "source": [ 43 | "Project Focus\n", 44 | "---\n", 45 | "- Know your main interest in programming: If you had infinite programming skills, what would you want to build?" 46 | ] 47 | }, 48 | { 49 | "cell_type": "markdown", 50 | "metadata": {}, 51 | "source": [ 52 | "Other skills and knowledge areas\n", 53 | "---\n", 54 | "- Databases\n", 55 | "- Sysadmin skills" 56 | ] 57 | } 58 | ], 59 | "metadata": {} 60 | } 61 | ] 62 | } -------------------------------------------------------------------------------- /notebooks/css/bootstrap_overrides.css: -------------------------------------------------------------------------------- 1 | /* Prevent double-highlighting of code cells. */ 2 | pre { 3 | border: 0px solid #999; 4 | background-color: #f7f7f7; 5 | } 6 | 7 | /* Probably unnecessary; was helping highlight active elements. */ 8 | ul.navbar-nav { 9 | border: 0px solid #333; 10 | padding-top: 7px; 11 | padding-bottom: 7px; 12 | } 13 | 14 | /* Disable highlighting of navbar elements for active sections. */ 15 | .navbar-default .navbar-nav > .active > a { 16 | background-color: #f8f8f8; 17 | } 18 | 19 | /* For now, I like the fixed navbar. Will re-evaluate. 20 | /* Don't fix the navbar to the top of the screen. 21 | .navbar.navbar-default.navbar-fixed-top { 22 | position: static; 23 | margin-top: -70px; 24 | } 25 | */ 26 | 27 | /* --- INDEX PAGE STYLES --- */ 28 | /* a sub-hero unit, for sections lower on the page */ 29 | .my_hero_unit_2 { 30 | padding: 15px; 31 | padding-bottom: 5px; 32 | border: 0px solid #333; 33 | margin-bottom: 10px; 34 | } 35 | 36 | /* Headers for the main sections on the index page. */ 37 | .section_label { 38 | font-size: 24px; 39 | } 40 | 41 | p.lead { 42 | margin-bottom: 0px; 43 | } 44 | 45 | hr { 46 | margin-top: 5px; 47 | margin-bottom: 5px; 48 | border-top: 1px solid #999; 49 | } 50 | 51 | .section_button { 52 | margin-top: 10px; 53 | margin-bottom: 5px; 54 | width: 400px; 55 | } 56 | 57 | .btn_home_action { 58 | margin-top: 3px; 59 | padding-top: 2px; 60 | padding-bottom: 2px; 61 | font-size: 14px; 62 | width: 200px; 63 | } 64 | 65 | .dropdown-menu .divider { 66 | margin-left: 10px; 67 | margin-right: 10px; 68 | border-bottom: 1px solid #ddd; 69 | } 70 | -------------------------------------------------------------------------------- /notebooks/my_templates/intro_python_header.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Introduction to Python: An open resource for students and teachers 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 32 | 33 | 34 | 37 | 38 | 39 | 40 | 41 | {% include "my_templates/ignored_templates/ga.tpl" ignore missing %} 42 | 43 | -------------------------------------------------------------------------------- /notebooks/exceptions.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "metadata": { 3 | "name": "exceptions" 4 | }, 5 | "nbformat": 3, 6 | "nbformat_minor": 0, 7 | "worksheets": [ 8 | { 9 | "cells": [ 10 | { 11 | "cell_type": "markdown", 12 | "metadata": {}, 13 | "source": [ 14 | "Exceptions\n", 15 | "===\n", 16 | "Every program has errors while it runs, and has to deal with unexpected behavior and bad input. Exceptions provide a clean way to deal with these situations." 17 | ] 18 | }, 19 | { 20 | "cell_type": "markdown", 21 | "metadata": {}, 22 | "source": [ 23 | "[Previous: Classes](http://nbviewer.ipython.org/urls/raw.github.com/ehmatthes/intro_programming/master/notebooks/classes.ipynb) | \n", 24 | "[Home](http://nbviewer.ipython.org/urls/raw.github.com/ehmatthes/intro_programming/master/notebooks/index.ipynb) | \n", 25 | "[Next: Testing](http://nbviewer.ipython.org/urls/raw.github.com/ehmatthes/intro_programming/master/notebooks/testing.ipynb)" 26 | ] 27 | }, 28 | { 29 | "cell_type": "markdown", 30 | "metadata": {}, 31 | "source": [ 32 | "Contents\n", 33 | "===" 34 | ] 35 | }, 36 | { 37 | "cell_type": "markdown", 38 | "metadata": {}, 39 | "source": [ 40 | "[top](#)" 41 | ] 42 | }, 43 | { 44 | "cell_type": "markdown", 45 | "metadata": {}, 46 | "source": [ 47 | "- - -\n", 48 | "[Previous: Classes](http://nbviewer.ipython.org/urls/raw.github.com/ehmatthes/intro_programming/master/notebooks/classes.ipynb) | \n", 49 | "[Home](http://nbviewer.ipython.org/urls/raw.github.com/ehmatthes/intro_programming/master/notebooks/index.ipynb) | \n", 50 | "[Next: Testing](http://nbviewer.ipython.org/urls/raw.github.com/ehmatthes/intro_programming/master/notebooks/testing.ipynb)" 51 | ] 52 | } 53 | ], 54 | "metadata": {} 55 | } 56 | ] 57 | } -------------------------------------------------------------------------------- /notebooks/testing.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "metadata": { 3 | "name": "testing" 4 | }, 5 | "nbformat": 3, 6 | "nbformat_minor": 0, 7 | "worksheets": [ 8 | { 9 | "cells": [ 10 | { 11 | "cell_type": "markdown", 12 | "metadata": {}, 13 | "source": [ 14 | "Testing\n", 15 | "===\n", 16 | "The programs that we write can quickly become complicated, and with complexity comes bugs. Programmers have long accepted that every program will have its share of bugs. To deal with this, we have come up with many ways to defend against avoidable bugs. Learning to write tests is one of the best things you can do to guard against avoidable bugs creeping into your own programs. Basically, you write a set of tests that you then run against your program every time you or someone else changes the program. These tests, if written correctly, prove that changes to the code do not break anything that was working previously." 17 | ] 18 | }, 19 | { 20 | "cell_type": "markdown", 21 | "metadata": {}, 22 | "source": [ 23 | "[Previous: Exceptions](http://nbviewer.ipython.org/urls/raw.github.com/ehmatthes/intro_programming/master/notebooks/exceptions.ipynb) | \n", 24 | "[Home](http://nbviewer.ipython.org/urls/raw.github.com/ehmatthes/intro_programming/master/notebooks/index.ipynb)" 25 | ] 26 | }, 27 | { 28 | "cell_type": "markdown", 29 | "metadata": {}, 30 | "source": [ 31 | "Contents\n", 32 | "===" 33 | ] 34 | }, 35 | { 36 | "cell_type": "markdown", 37 | "metadata": {}, 38 | "source": [ 39 | "[top](#)" 40 | ] 41 | }, 42 | { 43 | "cell_type": "markdown", 44 | "metadata": {}, 45 | "source": [ 46 | "- - -\n", 47 | "[Previous: Exceptions](http://nbviewer.ipython.org/urls/raw.github.com/ehmatthes/intro_programming/master/notebooks/exceptions.ipynb) | \n", 48 | "[Home](http://nbviewer.ipython.org/urls/raw.github.com/ehmatthes/intro_programming/master/notebooks/index.ipynb)" 49 | ] 50 | } 51 | ], 52 | "metadata": {} 53 | } 54 | ] 55 | } -------------------------------------------------------------------------------- /notebooks/js/html5shiv.js: -------------------------------------------------------------------------------- 1 | /* 2 | HTML5 Shiv v3.6.2pre | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed 3 | */ 4 | (function(l,f){function m(){var a=e.elements;return"string"==typeof a?a.split(" "):a}function i(a){var b=n[a[o]];b||(b={},h++,a[o]=h,n[h]=b);return b}function p(a,b,c){b||(b=f);if(g)return b.createElement(a);c||(c=i(b));b=c.cache[a]?c.cache[a].cloneNode():r.test(a)?(c.cache[a]=c.createElem(a)).cloneNode():c.createElem(a);return b.canHaveChildren&&!s.test(a)?c.frag.appendChild(b):b}function t(a,b){if(!b.cache)b.cache={},b.createElem=a.createElement,b.createFrag=a.createDocumentFragment,b.frag=b.createFrag(); 5 | a.createElement=function(c){return!e.shivMethods?b.createElem(c):p(c,a,b)};a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+m().join().replace(/\w+/g,function(a){b.createElem(a);b.frag.createElement(a);return'c("'+a+'")'})+");return n}")(e,b.frag)}function q(a){a||(a=f);var b=i(a);if(e.shivCSS&&!j&&!b.hasCSS){var c,d=a;c=d.createElement("p");d=d.getElementsByTagName("head")[0]||d.documentElement;c.innerHTML="x"; 6 | c=d.insertBefore(c.lastChild,d.firstChild);b.hasCSS=!!c}g||t(a,b);return a}var k=l.html5||{},s=/^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,r=/^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,j,o="_html5shiv",h=0,n={},g;(function(){try{var a=f.createElement("a");a.innerHTML="";j="hidden"in a;var b;if(!(b=1==a.childNodes.length)){f.createElement("a");var c=f.createDocumentFragment();b="undefined"==typeof c.cloneNode|| 7 | "undefined"==typeof c.createDocumentFragment||"undefined"==typeof c.createElement}g=b}catch(d){g=j=!0}})();var e={elements:k.elements||"abbr article aside audio bdi canvas data datalist details figcaption figure footer header hgroup mark meter nav output progress section summary time video",version:"3.6.2pre",shivCSS:!1!==k.shivCSS,supportsUnknownElements:g,shivMethods:!1!==k.shivMethods,type:"default",shivDocument:q,createElement:p,createDocumentFragment:function(a,b){a||(a=f);if(g)return a.createDocumentFragment(); 8 | for(var b=b||i(a),c=b.frag.cloneNode(),d=0,e=m(),h=e.length;d li { 78 | float: left; 79 | } 80 | .navbar-nav > li > a { 81 | padding: 15px; 82 | } 83 | 84 | /* Redeclare since we override the float above */ 85 | .navbar-nav.navbar-right { 86 | float: right; 87 | } 88 | 89 | /* Undo custom dropdowns */ 90 | .navbar .open .dropdown-menu { 91 | position: absolute; 92 | float: left; 93 | background-color: #fff; 94 | border: 1px solid #cccccc; 95 | border: 1px solid rgba(0, 0, 0, 0.15); 96 | border-width: 0 1px 1px; 97 | border-radius: 0 0 4px 4px; 98 | -webkit-box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175); 99 | box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175); 100 | } 101 | .navbar .open .dropdown-menu > li > a { 102 | color: #333; 103 | } 104 | .navbar .open .dropdown-menu > li > a:hover, 105 | .navbar .open .dropdown-menu > li > a:focus, 106 | .navbar .open .dropdown-menu > .active > a, 107 | .navbar .open .dropdown-menu > .active > a:hover, 108 | .navbar .open .dropdown-menu > .active > a:focus { 109 | color: #fff !important; 110 | background-color: #428bca !important; 111 | } 112 | .navbar .open .dropdown-menu > .disabled > a, 113 | .navbar .open .dropdown-menu > .disabled > a:hover, 114 | .navbar .open .dropdown-menu > .disabled > a:focus { 115 | color: #999 !important; 116 | background-color: transparent !important; 117 | } 118 | -------------------------------------------------------------------------------- /scripts/build_html_pages.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # This script builds the entire html page. 4 | # Assumes need to build from basic html, and construct custom-defined pages. 5 | # 6 | # When starting out, need to run a full nbconvert, and then pull out css and js 7 | # files into 'css' and 'js' directories, in the 'notebooks' dir. This is manual 8 | # right now, but it would be good to automate this and create a flag such as 9 | # '--initial'. 10 | # 11 | # Core of script involves running 12 | # 'ipython nbconvert --template intro_python_base.tpl' 13 | # Then adds appropriate sections through other templates, and scripting. 14 | # Also modifies some styles for better static html output. 15 | # Script is meant to be fairly straightforward to modify, so users can 16 | # build the static pages they care to make from the core notebooks. 17 | # 18 | # This is meant to work well through a post-commit-hook, although you can also 19 | # run the script manually when you want a snapshot of the notebooks in html 20 | # format. 21 | # 22 | # All html files are ignored by git. 23 | 24 | 25 | if [ -e scripts/ ] 26 | then 27 | # Probably running as a commit hook. 28 | path_to_scripts="scripts/" 29 | path_to_notebooks="notebooks/" 30 | else 31 | # Probably running directly from /scripts directory. 32 | path_to_scripts="" 33 | path_to_notebooks="../notebooks/" 34 | fi 35 | printf "\npath to scripts: $path_to_scripts" 36 | printf "\npath to notebooks: $path_to_notebooks\n" 37 | 38 | # Build basic pages. 39 | source "$path_to_scripts"create_common_html.sh 40 | wait 41 | 42 | # Add stylesheet to make output display initially on Mapping Global Earthquake Activity. 43 | printf "\n\nMake output display by default on specified notebooks..." 44 | #before_string="" 45 | before_string="" 46 | css_js_link_string="\n" 47 | sed -i "s/$before_string/$before_string\n\n$css_js_link_string\n/" "$path_to_notebooks/visualization_earthquakes.html" 48 | printf "\n Finished.\n\n" 49 | 50 | # Add elements to toggle output on each page. 51 | printf "Adding ability to toggle output on each page...\n" 52 | python "$prefix"show_hide_output.py 53 | wait 54 | printf " Added toggling ability.\n\n" 55 | 56 | # Convert index.html links to ./ 57 | source "$prefix"convert_home_links.sh 58 | wait 59 | 60 | # Highlight lines of code. 61 | python "$prefix"highlight_code.py 62 | wait 63 | 64 | # Highlight inline blocks of code. 65 | source "$prefix"highlight_inline_code.sh 66 | wait 67 | 68 | # Strip input references from code cells. 69 | python "$prefix"remove_input_references.py 70 | wait 71 | 72 | # Build index page. 73 | printf "\nBuilding index page...\n" 74 | python "$prefix"build_index.py 75 | wait 76 | printf " Built index page.\n" 77 | 78 | # Build all exercises page. 79 | # DEV: Holding off on this until project is more mature, 80 | # but don't want to lose sight of it. 81 | #python "$prefix"build_all_exercises_page.py 82 | #wait 83 | -------------------------------------------------------------------------------- /notebooks/index.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "Introduction to Python\n", 8 | "===\n", 9 | "Introduction to Python is a resource for students who want to learn Python as their first language, and for teachers who want a free and open curriculum to use with their students.\n", 10 | "\n", 11 | "If you are viewing the project through IPython Notebook Viewer, you might want to visit the student-facing pages at [introtopython.org](http://introtopython.org). There is a cleaner navigation there, and some better overall styling." 12 | ] 13 | }, 14 | { 15 | "cell_type": "markdown", 16 | "metadata": {}, 17 | "source": [ 18 | "Start Learning Python\n", 19 | "---\n", 20 | "If your computer is already set up to run Python programs, you can get started with [Hello World](http://nbviewer.ipython.org/urls/raw.github.com/ehmatthes/intro_programming/master/notebooks/hello_world.ipynb), your very first Python program." 21 | ] 22 | }, 23 | { 24 | "cell_type": "markdown", 25 | "metadata": {}, 26 | "source": [ 27 | "Set Up Your Programming Environment\n", 28 | "---\n", 29 | "If your computer is not yet set up to run Python programs, we can show you how to [get Python up and running](http://nbviewer.ipython.org/urls/raw.github.com/ehmatthes/intro_programming/master/notebooks/programming_environment.ipynb)." 30 | ] 31 | }, 32 | { 33 | "cell_type": "markdown", 34 | "metadata": {}, 35 | "source": [ 36 | "Contribute\n", 37 | "---\n", 38 | "If you already know Python and would like to help build Introduction to Python, see the project's [GitHub page](https://github.com/ehmatthes/intro_programming). You might want to look at [Issue 17](https://github.com/ehmatthes/intro_programming/issues/17), which discusses a few specific ways you can contribute to the project." 39 | ] 40 | }, 41 | { 42 | "cell_type": "markdown", 43 | "metadata": {}, 44 | "source": [ 45 | "Feedback\n", 46 | "---\n", 47 | "If you have any questions or comments, feel free to get in touch:\n", 48 | "\n", 49 | "Overall feedback: [Issue 10](https://github.com/ehmatthes/intro_programming/issues/10) on GitHub.\n", 50 | "Twitter: [@ehmatthes](https://twitter.com/ehmatthes)\n", 51 | "Email: ehmatthes at gmail dot com" 52 | ] 53 | }, 54 | { 55 | "cell_type": "markdown", 56 | "metadata": {}, 57 | "source": [ 58 | "About\n", 59 | "---\n", 60 | "I teach high school math and science, and I also teach an Introduction to Programming class each fall. This project started as a series of IPython Notebooks I wrote when teaching this year's programming class." 61 | ] 62 | } 63 | ], 64 | "metadata": { 65 | "kernelspec": { 66 | "display_name": "Python 3", 67 | "language": "python", 68 | "name": "python3" 69 | }, 70 | "language_info": { 71 | "codemirror_mode": { 72 | "name": "ipython", 73 | "version": 3 74 | }, 75 | "file_extension": ".py", 76 | "mimetype": "text/x-python", 77 | "name": "python", 78 | "nbconvert_exporter": "python", 79 | "pygments_lexer": "ipython3", 80 | "version": "3.4.3" 81 | } 82 | }, 83 | "nbformat": 4, 84 | "nbformat_minor": 0 85 | } 86 | -------------------------------------------------------------------------------- /notebooks/my_templates/index_body.html: -------------------------------------------------------------------------------- 1 |
2 | 6 | 7 | 8 | 9 | 16 | 17 | 18 | 19 |

Start Learning Python

20 |

If your computer is already set up to run Python programs, you can get started with Hello World, your very first Python program.

21 |

Hello World »

22 | 23 |

Set Up Your Programming Environment

24 |

If your computer is not yet set up to run Python programs, we can show you how to get Python up and running.

25 |

Environment »

26 | 27 |

Contribute

28 |

If you already know Python and would like to help build Introduction to Python, see the project's GitHub page. You might want to look at Issue 17, which discusses a few specific ways you can contribute to the project.

29 |

Contribute »

30 | 31 |

Support

32 |

If you would like to support this project, you can visit my Gratipay page. Even if you don't support me specifically, you might want to check out the Gratipay homepage and about page. It's a wonderful and important project to be aware of.

33 |

Gratipay »

34 | 35 |

Feedback

36 |

If you have any questions or comments, feel free to get in touch:

37 |
    38 |
  • Overall feedback: Issue 10 on GitHub.
  • 39 |
  • Twitter: @ehmatthes 40 |
  • Email: ehmatthes at gmail dot com
  • 41 |
42 | 43 |

About

44 |

I teach high school math and science, and I also teach an Introduction to Programming class each fall. This project started as a series of IPython Notebooks I wrote when teaching this year's programming class.

45 | 46 |

47 |

48 | 49 |
50 | -------------------------------------------------------------------------------- /scripts/show_hide_output.py: -------------------------------------------------------------------------------- 1 | # This script runs through all the html files in notebooks/, and adds 2 | # in code to allow toggling of output. 3 | 4 | import os 5 | import re 6 | import sys 7 | 8 | # Find all files to work with. 9 | path_to_notebooks = '/srv/projects/intro_programming/intro_programming/notebooks/' 10 | filenames = [] 11 | for filename in os.listdir(path_to_notebooks): 12 | if '.html' in filename and filename != 'index.html': 13 | filenames.append(filename) 14 | 15 | # Test with one simple file. 16 | #filenames = ['hello_world.html'] 17 | 18 | 19 | def generate_button(id_number): 20 | # Generate the button code to place before each div.output 21 | button_string = "
\n" 22 | button_string += " \n" % (id_number, id_number) 23 | button_string += " \n" % (id_number, id_number) 24 | button_string += "
\n" 25 | return button_string 26 | 27 | def generate_show_hide_all_buttons(): 28 | # Generate the buttons that show or hide all output. 29 | button_string = "
\n" 30 | button_string += " \n" 31 | button_string += " \n" 32 | button_string += "
\n" 33 | return button_string 34 | 35 | # Determine which files have output. Only add buttons to files with output. 36 | files_with_output = [] 37 | for filename in filenames: 38 | f = open(path_to_notebooks + filename, 'r') 39 | lines = f.readlines() 40 | f.close() 41 | 42 | target_string = '