Skip to content

Instantly share code, notes, and snippets.

View joetechem's full-sized avatar
💭
Focusing on Cloud Arch responsibilities

joe joetechem

💭
Focusing on Cloud Arch responsibilities
View GitHub Profile
@joetechem
joetechem / random_number_use_binary_search_method.py
Created December 8, 2016 18:19
random_number_use_binary_search_method.py
import random
number = random.randint(1, 100)
print number
GameRunning = True
while True:
guess = int(raw_input("Guess a number between 1-100: "))
if guess == number:
GameRunning = True
print("You guessed correctly!")
elif guess > number:
@joetechem
joetechem / for_loop_variable.py
Created December 13, 2016 19:42
a simple gist to show how you can use a for loop and create a variable to use that variable
# A simple program to demonstrate using a for loop
# To print hello world! five times in Python, you could type
# print('hello world!') five times, each on its own line
# Or, you could use a 'for loop' to have the same result with less typing:
for x in range (0, 5):
print('hello world!')
# The range function can create a list of numbers ranging from a starting number
# to the number just before the ending number.
@joetechem
joetechem / snake_pygame.py
Last active January 2, 2017 21:24
basic snake game using pygame, boundary event now working
# BASIC SNAKE GAME
# python 2.7
import pygame
import time
import random
pygame.init()
black = (0, 0, 0)
white = (255, 255, 255)
@joetechem
joetechem / random_number_start.py
Created January 10, 2017 16:15
random_number_start.py
import random # importing the random module
number = random.randint(1, 100) # were are creating a variable to equal an array (or range) of numbers for the computer to choose from
GameRunning = True
while True: # make a loop
guess = # don't forget your indents
@joetechem
joetechem / calculator_turtle.py
Created January 23, 2017 22:32
calculator program using turtle as the output
import turtle
t = turtle.Turtle()
print("Give me a number")
number1 = raw_input()
print("Give me another number")
number2 = raw_input()
number1 = int(number1)
@joetechem
joetechem / snake_gist.py
Last active January 25, 2017 23:15
snake game pygame
# BASIC SNAKE GAME
import pygame
import time
import random
pygame.init()
black = (0, 0, 0)
white = (255, 255, 255)
red = (255, 0, 0)
@joetechem
joetechem / random_number_guess.py
Created January 27, 2017 18:55
random_number_guess
import random
number = random.randint(1, 100) # Here's the range of numbers the computer randomly chooses from
print number # this line is just so you can test/see the numbers the computer chooses from
# You likely want to comment this out once your whole program is running!
# GameRunning variable here
# Start your while loop here, Watch your indents below this loop!
guess = int(raw_input("Guess a number between 1-100: ")) # letting Python know this is an integer
if guess == number: # starting your condition statements
@joetechem
joetechem / nesting_intro_example.py
Created January 27, 2017 20:58
nesting dictionaries in a list
from dictionary import * # importing another program so we can use its code in this new program
# START WITH AN EMPTY LIST
classmates = []
# USING THE APPEND FUNCTION TO ADD DICTIONARIES TO THE EMPTY LIST
classmates.append(john)
classmates.append(jane)
classmates.append(sue, james, bart) # adding multiple dictionaries at one time
@joetechem
joetechem / snake_pygame_lecture.py
Created February 1, 2017 18:50
starting point for snake game lecture
# Python 2.7
# Objectives: modules, game surface, Frames/sec (FPS), "skeleton" of a game, game loop, color,
# setting object size, random, lists
# Rather than typing from scratch (only ~50min of lecture available), students will
# each have these lines of code for a basic snake game using pygame.
# Lines will either be omitted or commented out
# students will follow along via the instructor/whiteboard; either typing in a few lines of code where its needed
# and/or students will uncomment lines of code that carry out specific feature related to the objectives
@joetechem
joetechem / empty_dictionary.py
Last active February 10, 2017 00:53
showing an empty python dictionary
# Python 2.7
# By Joe
# Below is a basic review of dictionaries in Python
# starting with an empty dictionary, then adding information to it
# Example:
# MAKE AN EMPTY DICTIONARY
john = {}
# ADDING KEY-VALUE PAIRS TO THE DICTIONARY