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 / hello_world.py
Last active November 1, 2023 23:07
the hello world program using the python language. A classic intro to programming.
# Python 2.7
# let's have the computer tell us "hello world!"
# Remember, a computer program is a set of instructions we tell the computer what to do.
print("Hello World!")
# When we run the program, Python returns the string inside the parentheses
# a string is just any series of letters, numbers, or symbols. Think of it as a line of text.
@joetechem
joetechem / echo.py
Created February 23, 2017 15:02
simple user input
# Python 2.7
# A simple program to have the computer take input from the user... Or so it seems!
message = ("Tell me something, and I will repeat it back to you: ")
print(message)
# Now, the message is printed, but the user cannot type anyhting in!
# What function do we need to add and where?
@joetechem
joetechem / data1_gist.py
Created February 22, 2017 13:53
wray's data lecture
# By: Wray
# Pre-req's : loops, conditionals, functions, lists, tuples, and dictionaries
#
# Python 2.7
#
# Objectives : Advanced dicionaries, Overloaded term: index, Multiple indexes
# Data is at the heart of most computation. Remember, the earliest computers helped people
# "store" their counts - tally sticks. Today's computer systems are excellent data storage
# systems. So, it makes sense to learn some about how computer programs store and retrieve data.
# The following is a gist of gist by Wray.
# We know all about loops and conditionals, so let's create a simple search by first name.
# Here's where we define our function
def find_contact_by_first_name(first_name):
for contact in contacts: # and here is our for loop found within the function's block of code
if contact[0] == first_name:
return contact
contact = find_contact_by_first_name("John")
@joetechem
joetechem / poll_test.py
Created February 21, 2017 22:38
more nesting
# Python 2.7
# Example from Python Crash Course
# Here's another example of nesting a list inside of a dictionary
# looking at our previous example of a dicitonary of similar objects
favorite_languages = {
'jen': ['python', 'ruby'],
'sarah': ['c'],
'edward': ['ruby', 'go'],
'phil': ['python', 'haskell'],
@joetechem
joetechem / favorite_languages_poll.py
Created February 15, 2017 18:24
dictionaries: dictionary of similar objects
# Python 2.7
# example from Python Crash Course by Eric Matthes
# you can store different kinds of information about one object in a dictionary,
# you can also use a dictionary to store one kind of information about many objects.
# Let's say we wanted to poll a number of people and ask them what their favorite programming language is.
# A dictionary can be useful for storing the results of a simple poll:
@joetechem
joetechem / pizza.py
Last active February 15, 2017 18:38
quick view at nesting: Python list in a dictionary
# Python 2.7
# example from Python Crash Course by Eric Matthes
# store info about a pizza being ordered
# list in a dictionary
pizza = {
'crust':'thick',
'toppings': ['mushrooms', 'pepperoni', 'extra cheese'],
}
# summarize the order:
@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 / 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 / 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