Skip to content

Instantly share code, notes, and snippets.

View macloo's full-sized avatar
💭
Teaching some Python

Mindy McAdams macloo

💭
Teaching some Python
View GitHub Profile
@macloo
macloo / argv_test1.py
Last active January 3, 2016 17:08
These tiny, simple files are derived from Zed Shaw's free online book _Learn Python the Hard Way_. These files accompany Zed's exercises 15 - 17. I wrote a quiz for students to test themselves - see the URL at the top of each file here. There are 4 Python files and 2 text files.
# see http://bit.ly/mmpython2 for the quiz
# compare the way this runs to the way argv_test2.py runs
# to run:
# python argv_test1.py first.txt
from sys import argv
script, filename = argv
txt = open(filename)
@macloo
macloo / functions1.py
Created January 18, 2014 17:32
These tiny, simple files are derived from Zed Shaw's free online book _Learn Python the Hard Way_. These files accompany Zed's exercises 18 and 19, in which he introduces functions. I wrote a quiz for students to test themselves - see the URL at the top of each file here.
# this is the answer to questions 16 and 17 in Practice with Python, Part 2 - Self-Quiz
# see http://bit.ly/mmpython2 for the quiz
def myname():
print 'Mindy'
print 'McAdams'
def anyname(a, b):
print a
print b
@macloo
macloo / ex43_v1.py
Created January 30, 2014 01:00
Three iterations of a text-based game to learn object-oriented techniques in Python. Based on exercise 43 in Zed Shaw's book. I did 7 distinct iterations but there's no reason to show all of them. Probably this code is bad in many ways. But each one of these runs without errors.
# Exercise 43: Basic Object-Oriented Analysis and Design
# http://learnpythonthehardway.org/book/ex43.html
# STAGE 1 - this works
# only classes Map and Engine are really built
# each Scene child-class can be run
# start w/ skeleton from Zed, then build it out
class Scene(object):
@macloo
macloo / alien_while_loop.py
Created February 2, 2014 22:35
Example of a while loop for beginners. Also an if-statement to help them figure things out.
# alien example - if-elif-else, and while loop
from random import randint # allows you to generate a random number
# variables for the alien
alive = True
stamina = 10
# this function runs each time you attack the alien
def report(s):
@macloo
macloo / test0209.py
Created February 10, 2014 03:07
Test for Alex
stuff = "Alex Randy Mandy"
other = "Jack Fletcher Isaac Bobby Susie Joey Manny Moe Jack"
apples = stuff.split(' ')
salad = other.split(' ')
basket = len(apples)
print basket
@macloo
macloo / turtle_circles.py
Created February 21, 2014 03:26
Use random numbers to make 100 circles with Python's turtle module.
# fun with turtle, a Python module
# draw 100 circles of many colors
# http://docs.python.org/3.1/library/turtle.html
# http://static.michael0x2a.com/turtle_examples.html
# http://www.eg.bucknell.edu/~hyde/Python3/TurtleDirections.html
import random
import time
import turtle
t = turtle.Pen()
@macloo
macloo / app.html
Created December 11, 2015 03:44
Attempt to get Bootstrap table controls to work with Tabletop.js - failed
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>PointRider</title>
<!-- Bootstrap -->
<!-- changed order so table comes after Bootstrap -->
<link href="bootstrap3/css/bootstrap.css" rel="stylesheet">
@macloo
macloo / radiobuttons 1
Created December 11, 2015 19:19
Get value of radio button set
var radioButtons = document.getElementsByName("taste");
for ( var i in radioButtons ) {
if ( radioButtons[i].checked ) {
var checkedButton = radioButtons[i].value;
break;
}
}
if (checkedButton == "salty") {
@macloo
macloo / lightbox.html
Created December 12, 2015 00:49
Simple lightbox - all code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Simple Lightbox</title>
<style>
/* overlay dims screen for simple lightbox */
@macloo
macloo / index.html
Last active January 6, 2020 19:43
Starter file for shoutbox project
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name=viewport content="width=device-width, initial-scale=1">
<title> My Shoutbox Project </title>
<link rel="stylesheet" href="css/main.css">
</head>
<body>
<div id="container">