This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Here, I am importing the sound library | |
import sound | |
# Here, I am importing the time library | |
# | |
# | |
import time | |
# This is my function | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# 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): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Book: | |
def __init__(self,pages): | |
self.pages = pages | |
self.current_page = 0 | |
self.bookmark = 0 | |
def read(self): | |
return self.current_page |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Choose your own adventure game | |
# MARS | |
# I am importing the Button class we created -- I created mine in a file | |
# called button.py (in the same directory) | |
from button import * | |
# Create a window | |
win = GraphWin("Mars Adventure",500,600) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
OlderNewer