Skip to content

Instantly share code, notes, and snippets.

joe joetechem

Block or report user

Report or block joetechem

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:4ced486f0958e7ce85c67c9eeb29f730
import RPi.GPIO as GPIO
DEBUG = 1
GPIO.setmode(GPIO.BCM)
GREEN_LED = 4
RED_LED = 5
BLUE_LED = 26
@joetechem
joetechem / fav_color.py
Last active May 16, 2017
A simple I/O python program with a while loop.
View fav_color.py
"""
A simple program asking a user to guess the "computer's" favorite color.
The favorite color of the computer is set in a variable, favColor.
The computer checks the user's input to match the favColor variable.
If it is any color other than the computer's favorite color, the loop continues.
Otherwise, the loop is ended when the flag is set to False (or, the user enters the
exact string equal to the favColor variable.
This will be a given program that students in Game Design will execute. Once executed, they
will be prompted with a challenge to create their own program which models the concepts in
View bounce.py
import sys, pygame
pygame.init()
size = width, height = 600, 600
speed = [1, 1]
red = 130, 202, 154
screen = pygame.display.set_mode(size)
@joetechem
joetechem / random_number_game.py
Created Apr 10, 2017
program chooses from a range of random numbers for the user to guess
View random_number_game.py
# Python 2.7
# Code Em Level 2 - Icebreaker
# a program to generate random numbers by using the random module
# a random number is picked, and the user must guess the number between 1 and 100.
import random
number = random.randint(1, 100)
print("I'm thinking of number between 1 and 100")
print("Try to guess the number with as few attempts as possible")
@joetechem
joetechem / things.py
Last active Mar 14, 2017
using object-oriented programming to classify things; ultimately, to classify any 'dog'
View things.py
# Python 2.7
# CREATING AND USING A CLASS
# You can model model almost anything using classes.
# Let's start by defining classes from our first example.
class Things():
pass
@joetechem
joetechem / modern_computers.py
Last active Mar 13, 2017
using basic object-oriented programming to define a 'real-world' class of modern computers
View modern_computers.py
# Python 2.7
# CREATING AND USING A CLASS
# You can model almost anything using classes. Let's start by writing a simple
# class, Computer, that represents a modern computer --not one computer in particular, but any modern computer.
# What do we know about most modern computers?
# They have a name and can store memory.
# and many computers can take input and display input.
# The two pieces of information (name and memory capacity)
# and the two behaviors (input and output) can go in the class Computer,
@joetechem
joetechem / while_input.py
Created Mar 3, 2017
review of user input and intro to while loops
View while_input.py
# Let's get some input from the user.
name = raw_input('Please enter your name: ')
# How can we do something with the value that was entered?
# In other words, how can we display the user's name???
# one way, is a print statement with some concatenation (or adding strings and variables nad other characters)
print("Hello " + name + "!")
####
####
@joetechem
joetechem / introducing_loops.py
Last active Mar 2, 2017
introducing while loops
View introducing_loops.py
# Python 2.7
# example code from Crash Course Python by Eric Matthes
# Recall for loops
# The for loop takes a collection of items and executes a block of code once
# for each item in the collection.
# PYTHON WHILE LOOPS
# In contrast, the while loop runs as longs as (or while) a certain condition is true
@joetechem
joetechem / user_input.py
Last active Mar 2, 2017
a few exercises to learn how to write interactive programs
View user_input.py
# Python 2.7
# code examples and explanations from Python Crash Course by Eric Matthes
####
####
# echo.py
# A simple program to have the computer take input from the user... Or so it seems!
@joetechem
joetechem / vasos_fill_a_dictionary.py
Last active Feb 26, 2017
actively taking user input to store in a dictionary
View vasos_fill_a_dictionary.py
# Python 2.7
# In this example, the user's will be asked for their name and a stream or river they visited
# setting up empty dictionary
responses = {}
# Set a flag to indicate that polling is active.
polling_active = True
You can’t perform that action at this time.