This file contains hidden or 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
# LPTHW Exercise 43 | |
import random | |
""" This module contains classes which denote the Game and individual rooms of the game.""" | |
class Game(object): | |
""" | |
This class represents the Game. It is what you would expect in a game | |
engine. | |
This file contains hidden or 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
# LPTHW Exercise 43 | |
import random | |
""" This module contains classes which denote the Game and individual rooms of the game.""" | |
class Game(object): | |
def __init__(self): | |
self.cmds = {} | |
self.cmds["rooms"] = "Prints the list of available rooms" | |
self.cmds["room"] = "Print the name of the current room. If followed by an argument then user will be taken to that room" |
This file contains hidden or 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
# LPTHW Exercise 42 | |
from sys import exit | |
from random import randint | |
class Game(object): | |
def __init__(self, start): | |
self.quips = [ | |
"You died. You suck at this!", |
This file contains hidden or 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
from sys import exit | |
from random import randint | |
def death(): | |
quips = ["You died. You kinda suck at this.", | |
"Nice job, you died ...jackass.", | |
"Such a luser.", | |
"I have a small puppy that's better at this."] | |
print quips[randint(0, len(quips)-1)] |
This file contains hidden or 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
# LPTHW Exercise 40 | |
cities = {'CA': 'San Francisco', 'MI': 'Detroit', 'FL': 'Jacksonville'} | |
cities['NY'] = 'New York' | |
cities['OR'] = 'Portland' | |
def find_city(themap, state): | |
if state in themap: | |
return themap[state] |
This file contains hidden or 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
# LPTHW Exercise 39 | |
ten_things = "Apples Oranges Crows Telephone Light Sugar" | |
print "Wait there's not 10 things in that list, let's fix that." | |
stuff = ten_things = ten_things.split(' ') | |
more_stuff = ["Day", "Night", "Song", "Frisbee", "Corn", "Banana", "Girl", "Boy" | |
] |
This file contains hidden or 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
from sys import exit | |
import random | |
countries = [['India', 'New Delhi'], ['United States of America', 'New York'], ['Afghanistan', 'Kabul'], ['Australia', 'Canberra'], ['Austria', 'Vienna'], ['Cambodia', 'Phnom Penh']] | |
countries_answered = [] | |
def get_random_country_and_capital(): | |
randint = random.randint(0, countryCount-1) | |
country = countries[randint][0] |
This file contains hidden or 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
from sys import exit | |
def gold_room(): | |
print "This room is full of gold. How much do you take?" | |
next = raw_input("> ") | |
if "0" in next or "1" in next: | |
how_much = int(next) | |
else: | |
dead("Man, learn to type a number.") |
This file contains hidden or 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
# LPTHW Exercise 33 | |
i = 0 | |
numbers = [] | |
while i < 6: | |
print "At the top i is %d" % i | |
numbers.append(i) | |
i = i + 1 |
This file contains hidden or 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
#LPTHW Exercise 32 | |
the_count = [1, 2, 3, 4, 5] | |
fruits = ['apples', 'oranges', 'pears', 'apricots'] | |
change = [1, 'pennies', 2, 'dimes', 3, 'quarters'] | |
# this first kind of for-loop does through a list | |
for number in the_count: | |
print "This is count %d" % number |