Skip to content

Instantly share code, notes, and snippets.

@wray
wray / ItemDB.py
Created August 26, 2015 20:56
Item-App
# coding: utf-8
import ui
import shelve
# Setting up variables for the views (in lieu of using the NavigationView)
item_db = None
add_item = None
show_item = None
@wray
wray / ItemDB.py
Last active August 2, 2016 21:49
Item-App
# coding: utf-8
import ui
import shelve
# Setting up variables for the views (in lieu of using the NavigationView)
item_db = None
add_item = None
show_item = None
search_items = None
@wray
wray / sound.py
Created August 28, 2015 13:27
sound.py
# Here, I am importing the sound library
import sound
# Here, I am importing the time library
#
#
import time
# This is my function
#
@wray
wray / Wray's Story.py
Created August 31, 2015 21:56
Wray's Story.py
# Mad Libs!
print("Type in an adjective")
adj = raw_input()
print("Type in a noun")
noun1 = raw_input()
print("Type in another noun")
noun2 = raw_input()
# First of all, don't forget that lines (like this one) starting with
# the pound sign/hashtag are called "comments". We use them like I am
# here -- to help explain your code to other humans. All of these
# comment lines are ignored when your program is interpreted (run).
# They are ignored by the computer.
# Remember what the keyword "import" is doing here.
# And remember the term: identifier. "random" is an identifier for the
# imported library
import random
#
# An example program to calculate weight on moon after a certain number
# of years. We are assuming someone who currently weighs more than 150 will only
# gain .5 pounds a year, while lighter individuals will gain 2 pounds a year.
# This is the concept we just learned. Defining a function in python.
# We use a function to calculate moon weight, mWeight after a certain number
# of years, years.
def moon_weight(current_weight,years):
#
# To use these functions, you can run python and then import like -
# from binary_adder import *
#
# These methods carry out binary addition via 'digital logic'
# This is really what happens at the logic circuit level.
# So, this is a pretty abstract use of programming to illustrate
# what happens on silicon using code many, many, levels above that!
#
# Choose your own adventure game
# MARS
def bad_alien():
print("The object fires a laser at you!")
def friendly_alien():
print("A little alien comes from the object with some spare O2 for you.")
print("You land on mars and your oxygen generator has failed, so you only have a few hours on the planet. However, you see something in the distance! What do you do?")
choice = raw_input("A) Leave Now, B) Go to object, or C) Scan Object ")
@wray
wray / msdie_1.py
Last active April 29, 2016 20:57
Multi Sided Die
#
# Let's go back to some games and start
# playing with a multi-sided dice.
#
# Think of the dice and how we interact with the dice.
# We roll it and then we read the number.
#
# The self keyword is similar to a
# regular variable, except it is a variable for every object
# created. A way to access the object in the class definition code.
@wray
wray / book.py
Created April 18, 2016 18:29
Book
class Book:
def __init__(self,pages):
self.pages = pages
self.current_page = 0
self.bookmark = 0
def read(self):
return self.current_page