Skip to content

Instantly share code, notes, and snippets.

@joetechem
joetechem / make_your_grocery_list.py
Created Oct 21, 2016
make_your_grocery_list.py
View make_your_grocery_list.py
# a program to make your own grocery list
# What happens: python asks for a few items and their prices to be put into a grocery list
# this program shows functions, comments, varaiables, user input and FLOAT
print("give me a food product you want in your grocery list")
food = raw_input()
#foodp = int(input('enter food foodp = int(input('enter food pric: '))
#print("what is the price of that food?")
#food_price = raw_input()
@joetechem
joetechem / Python_List_Intro.py
Last active Oct 21, 2016
Python_List_Intro.py
View Python_List_Intro.py
# This program shows the difference between a strings and lists
# with a quick introduction to using functions with a list
# This is my typical grocery list stored as one single STRING
grocery_list_for_Joe = ['eggs, milk, dandruff shampoo, holy grail, 2 african swallows, coconut']
#print(grocery_list_for_Joe)
# Below is my grocery list created as a LIST instead of a STRING:
@joetechem
joetechem / if_elif.py
Created Nov 2, 2016
You are a tree condition statements
View if_elif.py
# If and Elif Statements
print("You are a tree.")
print("Tree, what is your name?")
tree_name = input()
print(tree_name + ", how old are you?")
tree_age = float(input())
if tree_age > 112:
print(tree_name + ", you are an old tree!")
elif tree_age < 112:
print(tree_name + ", do some more growing!")
View turtle_module_loop
for i in range(4):
t.forward(100) # notice the indentation
t.left(90)
# VERSUS
for i in range(4):
t.forward(100) # notice the lack of indentation here
t.left(90)
View commands.py
# coding: utf-8
print("type command: hello")
COMMAND1 = "hello"
def handle_command(command):
"""
Determine if the command is valid. If so, take action and return
a response, if neccessary.
"""
View command_respond.py
# coding: utf-8
# A simple command-respond program
# Python asks for input then carries out the specified action base don the condtions of the input
#COMMAND1 = "hello"
#def handle_command(command):
# response = ""
@joetechem
joetechem / tuples-maps-intro.py
Created Nov 10, 2016
Comparing lists, tuples and maps
View tuples-maps-intro.py
# a crude program to show examples of a tuple
# and relate to lists and strings
# a tuple is similar to a list, but uses parentheses
fibs = (0, 1, 1, 2, 3)
print(fibs[3])
# Above, we define the variable fibs as the numbers 0, 1, 1, 2, and 3.
# Just like a list, we print the item in the index position 3 in the tuple.
@joetechem
joetechem / techem
Last active Nov 29, 2016
script to run for chbooks
View techem
#! /usr/local/bin/bash
apt-get --assume-yes install matplotlib
apt-get --assume-yes install idle
apt-get --assume-yes install git
apt-get --assume-yes install python-setuptools
apt-get --assume-yes install python-dev
apt-get --assume-yes install build-essential
easy_install pip
apt-get --assume-yes install git-cola
@joetechem
joetechem / Mtn_Secenario_Adventure_Game.py
Last active Nov 29, 2016
Mtn_Secenario_Adventure_Game.py
View Mtn_Secenario_Adventure_Game.py
# Choose your own adventure game
# WIZARD MOUNTAIN
# a text-based choose your own adventure game
# This adventure is like an upside down tree with branches
# this program is full of blocks of code, known as branches, or code branches
# Make sure to visit every branch to make sure all of the code works
def parachute_fail():
View text_adventure.py
# Choose your own adventure game
# WIZARD MOUNTAIN
# a text-based choose your own adventure game
# This adventure is like an upside down tree with branches
# this program is full of blocks of code, known as branches, or code branches
# Make sure to visit every branch to make sure all of the code works
def parachute_fail():
You can’t perform that action at this time.